Page 1 of 1

Maximum Value from the table using MAX does'nt working

Posted: Wed Mar 04, 2009 11:14 am
by ullasvk
Hello friends,
I have a small problem in my code.
I have two tables 1. order_detail 2. inventory.
I want to take maximum value from the coloumn which is in the both tables and update it to new row in the order_detail table. the below code works, but only for the first time i.e., it takes the maximum value from the both table and add 1 to it and it updates, but after that it updates the table with value 2. I tried a lot but all in vain. Please any one help me.

Thanks in Advance

Code: Select all

 
 
$result1 = mysql_query("SELECT MAX(bun_no) from order_detail");
$a = mysql_fetch_array($result1);
$result2 = mysql_query("SELECT MAX(bun_no) from inventory");
$b = mysql_fetch_array($result2);
$c = ($a1>$b?$a1:$b);
$d = $c[0] + 1;
$result9 = mysql_query("UPDATE ORDER_DETAIL SET  BUN_NO = '$d' WHERE SL_NO ='$a[$i]'  ");
 
 

Re: Maximum Value from the table using MAX does'nt working

Posted: Wed Mar 04, 2009 11:39 am
by Mark Baker
$a1 or $a????

Code: Select all

 
$c = ($a1>$b?$a:$b);