Page 1 of 1

read out data for SWITCH

Posted: Wed Nov 30, 2005 8:00 pm
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 ());
	}
}
?>

Posted: Wed Nov 30, 2005 8:14 pm
by John Cartwright
Sorry what? Btw are those supposed to be constants? (VAT, N, J)

Posted: Wed Nov 30, 2005 8:45 pm
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!!!

Posted: Wed Nov 30, 2005 9:47 pm
by John Cartwright
Why not simply perform a query and get the value of VAT?

Posted: Wed Nov 30, 2005 11:39 pm
by joecrack
plz ... :roll:
tell me how

Posted: Thu Dec 01, 2005 12:20 am
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. :?

Posted: Thu Dec 01, 2005 1:24 am
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???

Posted: Thu Dec 01, 2005 1:31 am
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()

Posted: Thu Dec 01, 2005 1:52 am
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?

Posted: Thu Dec 01, 2005 2:00 am
by John Cartwright
post your code...

Posted: Thu Dec 01, 2005 2:14 am
by joecrack
okey got it finally :lol:
break; was missing !!!
thanks a lot Jcart

Posted: Thu Dec 01, 2005 4:32 am
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

Posted: Thu Dec 01, 2005 4:43 am
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: