I have an html form build from a MySQL table. The mysql table has 2 fields, itemnumber and status. Status is either 1 or 0. I do not know how many results may returned at any given time. In the sample below I show 4, but it could be any number of pairs.
The results are displayed using radio buttons on the html page. In the example below, x indicates it is checked. A check in the yes column means the mysql record had a value of 1 an no x (unchecked) means the value was 0.
Item Yes No
3 x
6 x
7 x
9 x
Up to this point I have no problem.
Now, the form is to be submitted and the status of the radio buttons must get updated in the mysql table. This is where I am stuck. I need some sort of for loop combined with an update command, but aren'r sure on what I am looping.
I have named each radio button form element by its item number. So, when I submit the form the following php variables are passed.
$3=1, $6=0, $7=0, $9=1
If I only had to update one record, say item 3, I would use the following mysql query .
"UPDATE tablename SET status = '$3' WHERE itemnumber = '3'"
But, I don't know what the items are or how many there are. I need to loop thru and substitute the 3 in the above update query with the correct value and do so for how ever many pairs there are with that paticular submission.
Any advise would be most appreciated.
Thank you,
-Bob