mulaus Posted August 9, 2013 Share Posted August 9, 2013 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... Link to comment https://forums.phpfreaks.com/topic/280973-updated-by/ Share on other sites More sharing options...
kicken Posted August 9, 2013 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 } Link to comment https://forums.phpfreaks.com/topic/280973-updated-by/#findComment-1444098 Share on other sites More sharing options...
mulaus Posted August 9, 2013 Author Share Posted August 9, 2013 thank you i got it Link to comment https://forums.phpfreaks.com/topic/280973-updated-by/#findComment-1444138 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.