Forum Moderators: coopster

Message Too Old, No Replies

road block on mass update

         

twistedperv

2:48 am on May 2, 2005 (gmt 0)

10+ Year Member



Ive having a terrible problem with one of my scripts. Here's what Ive got.

I have a database table named links, with around 600 or so links in it. The fields are link_id, link_url, link_description, link_status, link_report and a few others.

What my page does is call the db and pulls 15 entries out and displays them in a nice neat tabled list. Now the displayed data for each link_id is in its own text field and select box for things like category selection and so forth, this way my display page is also my edit page.

Now with all my data displayed and able to be edited, Im trying to make it to where I can edit any aspect of a link field and be able to submit all of the changes using one submit button at the bottom of the page.

Meaning I could change 2 or 3 things for link_id 1 and 1 thing for link_id 2 or maybe nothing for link_id's 5 and 6 and be able to have all of those changes updated in mysql in the corresponding id when I hit submit.

If anyone has a link to a tut, or has conquered this task recently I would greatly appreciate it.

ironik

2:59 am on May 2, 2005 (gmt 0)

10+ Year Member



There's a couple of options. The first is to store the information in a temporary array. What I normally do is populate an array from the database, then when you submit your form create an array with an identical structure from the POST variables. There are a ton of array functions in PHP, but you could use a simple foreach loop that goes through each entry... do your matching, and if it doesn't match build up an array of UPDATE SQL queries that you can run when the comparison has finished. That will allow you to only update information that has changed from it's previous version.

You could also pop a bit of javascript on the form that test's if the value has changed from it's original and builds a seperate hidden field of changed link id's, which is pretty easy to do, but if someone is going to be editing it with javascript turned off on the browser you run into big problems.