Jump to content

Recommended Posts

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:13
Q:1
Q:1
Q:12
P:3
P:5
P:1
P: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;

Link to comment
https://forums.phpfreaks.com/topic/279569-php-foreach-help/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.