Baabu Posted March 5, 2008 Share Posted March 5, 2008 what should i do that each record of each table should be update accordingly to the $qty $tables=array("Charger","Car_Charger","Desk_Charger","Hand_Free","Hand_Covers","Usb_Cables","Card_Read","Usb_Drive"); global $dbserver,$dbuser,$dbpass,$dbname;//same as above $cxn=ConnectToDb($dbserver,$dbuser,$dbpass,$dbname);//same as above $qty=0; $temp_query=0; for($i=0;$i<sizeof($tables);$i++) { $temp_query=mysql_query("select * from " . $tables[$i]) or die("Error in Final Query: ".mysql_error());; //$temp_result=mysql_fetch_array($temp_query); while($temp_result=mysql_fetch_array($temp_query)) { $qty=$temp_result["qty"]-$temp_result["tempqty"]; if($qty==0) { //echo "The Stock of ".$tables[$i]."Has finished"; // echo "Updating inxx $qty"; mysql_query("update ". $tables[$i] ." set qty='$qty' where model=model and type=type and code=code")or die ("Error in query orignal update".mysql_error()); } else if($qty>=1) { mysql_query("update ". $tables[$i] ." set qty='$qty'")or die ("Error in query orignal update".mysql_error()); } mysql_query("update ". $tables[$i] ." set tempqty='0'")or die ("Error in query orignal update".mysql_error()); } } well i want that this update query should update each record in the tables individually as this is setting the value of $qty to each row of the selected table with same value Quote Link to comment Share on other sites More sharing options...
Isityou Posted March 5, 2008 Share Posted March 5, 2008 Are you getting any errors? What exactly isn't working out for you? Quote Link to comment Share on other sites More sharing options...
Baabu Posted March 5, 2008 Author Share Posted March 5, 2008 no errors are there but when it comes to update it sets the same value of quantity for each record in the table but i want it to update each record according to its own value Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.