update table for several records

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I have a list of records as a result of a query. They are displayed
with a while sentence...

while($row = mysql_fetch_array($res))

at the end of each record, I inserted a checkbox because I need to
update all the records that the user checks in the checkbox. So, the
process is:

1) The PHP displays all the records with the "while"
2) The user checks one or more checkbox
3) Then Update the table where the record is checked

Each checkbox has an unique name. I understand how to update the table
with one record checked, but as the numbers of records to change can
variable, how do I do it???

Any help will be apprecciate!!

Best regards,


Re: update table for several records

zek2005 contained the following:

Quoted text here. Click to load it

Don't give each check box a unique name, give each check box the same
name only do it like this:  name= "check[]"  The value of the checkbox
should be the id of the record you want to change.

This will result in an array of values, $_REQUEST['check'], which you
can loop through using foreach.
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/

Re: update table for several records

Quoted text here. Click to load it

Use a loop and update each record in the table based on it's unique ID.  
Each record has a unique, primary ID, right?  Use that.

DeeDee, don't press that button!  DeeDee!  NO!  Dee...

Re: update table for several records

On Tue, 27 Dec 2005 07:45:04 -0800, zek2005 wrote:

Quoted text here. Click to load it

That's what the primary key is for.  


Site Timeline