So you display a website generated from a database with a bunch of form elements that correspond to various fields in the database, and you want to know which, if any of the form fields have been changed so you can update the database?
Assuming the above is correct, I seriously wouldn't bother. I doubt you'd gain any real benefit or efficiency from trying to only update the changed elements. Just update all of the fields with the form values. Any win from doing less updating is probably equally offset by the calculations involved in diffing.
Alternatively, storing the original value in a hidden field is probably the best bet. Sure you can't rely that the client hasn't changed the value of the hidden field, but what does that gain them? If they deliberately modify the hidden one to make it the same as the visible, you simply don't update the database and it's their loss. Other wise it works properly with the least amount of fuss.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.