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 Link to comment https://forums.phpfreaks.com/topic/94446-update-each-record-of-each-table/ 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? Link to comment https://forums.phpfreaks.com/topic/94446-update-each-record-of-each-table/#findComment-483682 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 Link to comment https://forums.phpfreaks.com/topic/94446-update-each-record-of-each-table/#findComment-483684 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.