Jump to content

convert forloop to foreach


vinpkl

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.