Multiple Field Submission

gazzieh

New Member
I have a form that takes fields from a SQL database and allows the user to make changes to the data. Each row represents a single record from the table.

The question is about submitting this data. I could create each record as an individual form; this would allow for the updating and deleting of individual records but stops the user making a mass submission of many changed records.

The other option is to have a single submit button and have this update all records in the database; but this clearly has a time issue; probably very slight since this is a small system, yet an issue nonetheless.

How would others approach this issue?
 

DHDdirect

New Member
You should be able to put some examine statements in your code to only update the database with the information from fields that have changed.
 

gazzieh

New Member
You should be able to put some examine statements in your code to only update the database with the information from fields that have changed.

Actually, the easiest way I have found so far is to have hidden fields with the original data and then, on the $_POST coding compare the two fields; if any changes then update the whole data row.
 

nafirici

New Member
Actually, the easiest way I have found so far is to have hidden fields with the original data and then, on the $_POST coding compare the two fields; if any changes then update the whole data row.

If you're going to use this approach, you could create an array of the values from the database in the same order that the POST would be in, then do a hash and implode and store the hash:

PHP:
   $hashVar = md5(implode($resultArray));

Then do the same with the POST:

PHP:
   $postCheck = md5(implode($_POST));

   if ($hashVar !== $postCheck) {
        // update records.
  }

This way you're not storing anything in the form that could be sensitive.
 
Top