mulaus Posted August 9, 2013 Share Posted August 9, 2013 (edited) Hi i would like to display in my data table the user who last updated the data I have this example $updated_by = $myUser->getVar('name'); echo "<input type='hidden' name='updated_by' value='$updated_by'>"; global $myDB; mysql_query("UPDATE ".$myDB->prefix("kmb_info")." SET name='" . mysql_escape_string(trim($_POST['name'])) . "', updated_by='" . mysql_escape_string(trim($_POST['updated_by'])) . "' WHERE id='".intval($id)."'") or die(mysql_error()); the problem is field updated_by is updated even when no change in name value when the edit form is submitted how do i do this..im new to this TQ... Edited August 9, 2013 by mulaus Quote Link to comment Share on other sites More sharing options...
Solution kicken Posted August 9, 2013 Solution Share Posted August 9, 2013 You'll have to do a comparison of the old record value to the new value. Only run your UPDATE query if there has actually been a change. if ($oldRecord['name'] != $_POST['name']){ //Do Update } Quote Link to comment Share on other sites More sharing options...
mulaus Posted August 9, 2013 Author Share Posted August 9, 2013 thank you i got it Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.