how to only bulk update rows of form data that were modified
Posted: Thu Nov 06, 2008 2:59 pm
I am trying to replicate functionality similar to what I've seen in PHPMyAdmin. When updating/editing table data, you have a bunch of form fields...one for each column. If you only change one value, the update statement that is submitted only updates that one row or field.
Basically, I have a table of products and I print them to a table of arrayed form fields. This is so I can tab through and make updates to all my product data and submit it all at once. When I submit, I iterate through the arrays and run update statements on every row. It's started to get bogged down now that I have hundreds of products. I would like to be able to change one value of one product, click "bulk update", and it only update the one record, instead of updating the other 100 records with the same data that was already in the database.
One idea I have is to dump the original values into a set of arrayed hidden input fields, and run a check against it, but it just feels like it would be cluttered.
I'm also worried it will double the size of my POST and possibly make performance even worse.
Open to any suggestions.
Basically, I have a table of products and I print them to a table of arrayed form fields. This is so I can tab through and make updates to all my product data and submit it all at once. When I submit, I iterate through the arrays and run update statements on every row. It's started to get bogged down now that I have hundreds of products. I would like to be able to change one value of one product, click "bulk update", and it only update the one record, instead of updating the other 100 records with the same data that was already in the database.
One idea I have is to dump the original values into a set of arrayed hidden input fields, and run a check against it, but it just feels like it would be cluttered.
Code: Select all
if ($oldfield1hiddenarray[$i] != $newfield1txtarray[$i] OR $oldfield2hiddenarray[$i] != $newfield2txtarray[$i] ETC....) {
$Query = "Update BLAH BLAH"; //Update this products data because something was modified
}Open to any suggestions.