PHP MySQL - How easy way to update the database when one or more fields value changed -


i have little problem on database update activity.

case study:

i created form php editing, , perform queries retrieve value of record wants updated. excerpts of script:

<?php   $row = mysql_fetch_assoc(mysql_query("select id, field_1, field_2 mytable id = $editid")); ?>   ...  <form action="" method="post">   field 1 <input type = "text" name = "f1v" value = "<? php echo $ row ['field_1'];?>" />   field 2 <input type = "text" name = "f2v" value = "<? php echo $ row ['field_2'];?>" />   <input type="submit" /> </form>  .... // when form posted  if ($_post) {    $f1v = $ _post['f1v'];    $f2v = $ _post['f2v'];     mysql_query("update mytable set field_1 = '$f1v', field_2 = '$f2v' id = $editid") or die ();     // redirect form } 

in case want when form submited, there activities check whether there change in 1 or more fields values. logic approximately this:

if ($ _post) {         // compare    if submitted value different existing value in record    {       updated record    }    else    {       not update record    }            // redirect form } 

do have easy way it? thank help.

don't bother checking. make sure entry valid , throw in.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -