update many values at once.

heyy... i need to knw how to update many values from one submit. problem is i have 10 fields and every text field has same table field value.assume that my 10 fields have 10 quantity values. i need to update quantity field by all 10 fields. like this ; 10 different items quantity should be update by clicking on submit button.(User select 10 different items from each combo boxes and enter quantity for each appropriate text field.)
I NEED is how to write query for this... please Help..

You should have a different name for each field. When you retrieve the values update them using the name. For example, if you have a field with name 'product123' the query should be something like this:

When you have multiple fields you can do a 'for each' to the $_POST element to update the values according to the name, but remember that when you submit a form the button is sent too so put a name to it.

yeahh... i put code in here with out for loop.. please can u do it for me.. because when i use for loop it get too much errors.please help me. with out for loop this code work nicely.. i dont knw how to use bt i can use $_POST["item$i"] and $_POST["textfield$i"] like this. can u please made this code as working.

i really need your help on this one, its for a school project, ive got 3 tables on phpmyadmin (product, stock and collaboration). my webpage shows the product the price, a dropbox to choose the quantity of each product and a submit button.

what im trying to do is reduce stock quantity from the stock table for a product with the quantity chosen from the drop box of that product. this is what ive been able to do so far:

It seems that you want the user to be capable of buying many items at once. Then each 'quantity' item should have a unique name that allows you to determine which product to update. So in the for loop each 'select' print could have the product's Id.

<select name="<?php echo $row_product['productId']?>" >

So when you retrieve all those quantity numbers you can use the foreach technique. The $key will be the product's id and the $val will be the quantity selected.

You should add a 0 option by default so you don't force the user to buy everything he sees on the screen. Also remember to omit the submit button which in this case has the name of 'formtype'

hi again,
ive tried what you suggested but it seems im just confusing myself the more. im new to php, can you educate me one the steps to take (pls break down these steps). this is what ive been able to do with your earlier advice:

The handler will only receive two items:
1. The submit button called 'submitButton'
2. The selected option which won't have a certain name, the name will change according to the item that has been purchased.

In the handler.php do an echo on the $_POST and you'll see those items.

thanks, i think im getting there now. now this is what i get when i click the purchase button: "update stock set amount = 3 where productID = '1001_'Array". 3 being the number chosen from the drop box and 1001 the prductID of the product, i dont want this mesage to show. i need the page to show a message when i click the purchase button and then stock table to reduce by the quantity 3.

Well now you have the query, you just need to execute it with mysql_query, but i think that the chosen quantity is not the final amount. You have to take out that quantity from the amount like amount = amount - 3; where 3 is the chosen quantity

The $a has a 'mysql_result' which is a special data type, $a does not contain the current stock. To get the current stock you must use mysql_fetch_array($a); just like when you retrieved certain fields from the product table