read out data for SWITCH

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
joecrack
Forum Commoner
Posts: 99
Joined: Mon Oct 31, 2005 9:17 pm

read out data for SWITCH

Post by joecrack »

this code is supposed to update a dataset.
my problem is, that the VAT value is allready in the dataset that i want to change (red).
i dont know how to get it out for the SWITCH or hot to write the command.!)!

Code: Select all

<?php
error_reporting(E_ALL);

if($_POST['exrate']>0){
	switch ([color=red]VAT[/color]){
		case J:
     $sql = "UPDATE sam_date_val SET tovalue=toamount*'" .$_POST['exrate']."'*'1.16'+amendment1+amendment2+amendment3 WHERE (projnr='$projnr' AND customernr='$customernr' AND contrdate='$contrdate')";
        mysql_query ($sql) or die ( 'MySQL-Fehler: ' . mysql_error ());

		case N:
     $sql = "UPDATE sam_date_val SET tovalue=toamount*'" .$_POST['exrate']."'+amendment1+amendment2+amendment3 WHERE (projnr='$projnr' AND customernr='$customernr' AND contrdate='$contrdate')";
        mysql_query ($sql) or die ( 'MySQL-Fehler: ' . mysql_error ());
	}
}
?>
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Sorry what? Btw are those supposed to be constants? (VAT, N, J)
joecrack
Forum Commoner
Posts: 99
Joined: Mon Oct 31, 2005 9:17 pm

Post by joecrack »

okey - i try to explain again ...
there is a dataset that will be updated by this code (tovalue=.....)
but but how it will be updated depends on the VAT, that is already saved IN the dataset that will be saved.
so VAT is not entered in the same form .... it is in the same dataset that i want to change - so switch(VAT)
will not be working i have to read out VAT from the dataset that will be chnaged.
Like switch(VAT from ... where ...) ... i hope you got it this time!!!
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Why not simply perform a query and get the value of VAT?
joecrack
Forum Commoner
Posts: 99
Joined: Mon Oct 31, 2005 9:17 pm

Post by joecrack »

plz ... :roll:
tell me how
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

From the information I've gathered

Code: Select all

$result = mysql_query(
   "SELECT `VAT` FROM `sam_date_val` WHERE (projnr='$projnr' AND customernr='$customernr' AND contrdate='$contrdate'";
);

$row = mysql_fetch_assoc($result);

switch ($row['VAT']){
        case 'J':
I'm still not sure as to what VAT will be returning. I am assuming it returning 'J' or 'N', but I cannot be sure. :?
joecrack
Forum Commoner
Posts: 99
Joined: Mon Oct 31, 2005 9:17 pm

Post by joecrack »

thx pretty good ... but its always doing the second case - means it is not realy checking if VAT is J/N .
that means assoc is not working right???
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

post your code.. make sure you quote both J and N

What is the result of

Code: Select all

echo $row['VAT'];
directly after mysql_fetch_assoc()
joecrack
Forum Commoner
Posts: 99
Joined: Mon Oct 31, 2005 9:17 pm

Post by joecrack »

yeah ... i also treid that after posting .. it is J !!!
So is the problem the SWITCH ???
Perhaps it cant deal with array or assoc?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

post your code...
joecrack
Forum Commoner
Posts: 99
Joined: Mon Oct 31, 2005 9:17 pm

Post by joecrack »

okey got it finally :lol:
break; was missing !!!
thanks a lot Jcart
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

Jcart wrote:post your code...
If you need a wall Jcart, I have some pretty good recommendations, namely walls that are quite soft.

:P
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

Jenk wrote:
Jcart wrote:post your code...
If you need a wall Jcart, I have some pretty good recommendations, namely walls that are quite soft.

:P
Cart-walling anyone :lol:
Post Reply