in reply to MySQL and Perl CGI

A solution depends rather on a few important factors:

  1. Are you already using session management?
  2. Will there be more than one "session" active at a time?
  3. Can you add a unique uneditable record ID to each editable table?
  4. Can you depend on JScript being enabled for the client?

If you are using session management then caching the last query then diffing against that to drive the database update seems ok, but may become interesting if multiple access is possible.

If you have unique record IDs you can put those in hidden fields on the web page so you can easily match up records.

If you have JScript available you can use it to post before and after versions of the edited records.

You could put all the original data into hidden fields that get posted back along with the edited fields.

There are many options and trade-offs of different sorts with each one.

True laziness is hard work