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 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 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. Link to comment https://forums.phpfreaks.com/topic/273625-convert-forloop-to-foreach/#findComment-1408151 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.