vinpkl Posted January 25, 2013 Share Posted January 25, 2013 hi The below code works fine. But i would like to know if this below code be written or converted to foreach loop intead of forloop $ppid = array(); $ppid = $_REQUEST['updt_pid']; $quantity = array(); $quantity = $_REQUEST['quantity']; for($i=0;$i<count($quantity);$i++) { $cart_update_query = "UPDATE cart_table SET quantity=$quantity[$i] where product_id=$ppid[$i]"; $cart_update_result=mysql_query($cart_update_query)or die(mysql_error()); } vineet Quote Link to comment https://forums.phpfreaks.com/topic/273625-convert-forloop-to-foreach/ Share on other sites More sharing options...
cyberRobot Posted January 25, 2013 Share Posted January 25, 2013 (edited) Have you tried the examples in the manual (http://php.net/manua...res.foreach.php)? Understanding the code may help you adapt the for loop. Edited January 25, 2013 by cyberRobot Quote Link to comment https://forums.phpfreaks.com/topic/273625-convert-forloop-to-foreach/#findComment-1408151 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.