Hi,
I'm having some trouble with something that should be relatively easy. I
want to update multiple rows in one of my database tables simultaneously.
In my table I have these values:
imageID
image_order
I want to be able to modify the image_order column where imageID = imageID.
imageID | image_order
1 | 1
2 | 2
3 | 3
4 | 4
5 | 5
I want to be able to pull these values into a form and allow the user to
edit the image_order value. So my updated table might look something like
this:
imageID | image_order
1 | 2
2 | 5
3 | 1
4 | 3
5 | 4
The problem lies in the form handling script. How can I pass multiple sets
of imageID / image_order values to an sql update query?
I can pass one set without problem. But I want the user to be able to edit
all of the image_order values from one page.
I've tried passing multiple image_order values by initialising an array and
using a foreach() loop to extract the values but I can't think of a way to
pass the corresponding imageID value. I can grab all the imageID values
again in my form handler script using an ORDER clause to ensure they are
pulled in the same order as the form script but again, I can think of no way
to combine this with the img_order array sent from my form.
How can I combine all of this data in one sql query that will update my
table?
Thanks in advance for any help.