lewisstevens1 Posted June 25, 2013 Share Posted June 25, 2013 Hi guys i just want to be able to add this form to a mysql update command E.g. mysql_query("UPDATE table SET product_quantity = '.$product_count.' WHERE product_id = '.$product_id.' "); for each array. I done some test below just to see how it is processed... i need it to add like... Q then P then Q then P. Im not sure how to do it, i tried adding two foreach commands inside each other although that came up with 3 times the results. I was trying to add two foreach in one statement so i could reference to both at the same time. All help would be great. Thanks! Q:13Q:1Q:1Q:12P:3P:5P:1P:4 include_once('content/page_header.php'); //POST VARS $quantity_post = $_POST['quantity']; $product_post = $_POST['product_id']; $string = ""; foreach($quantity_post as $quantity){ $string .= "Q:".$quantity."<br/>"; } foreach($product_post as $product){ $string .= "P:".$product."<br/>"; } echo $string; Quote Link to comment https://forums.phpfreaks.com/topic/279569-php-foreach-help/ Share on other sites More sharing options...
ginerjm Posted June 25, 2013 Share Posted June 25, 2013 Your query is flawed to begin with. Then you don't show us how you are executing the query. Would love to help but we need to see some more I think. Quote Link to comment https://forums.phpfreaks.com/topic/279569-php-foreach-help/#findComment-1437861 Share on other sites More sharing options...
lewisstevens1 Posted June 26, 2013 Author Share Posted June 26, 2013 Thanks but ive found the answer now Thanks anyway http://www.codingforums.com/showthread.php?p=1343259&posted=1#post1343259 Quote Link to comment https://forums.phpfreaks.com/topic/279569-php-foreach-help/#findComment-1437929 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.