blackdogupya Posted March 16, 2012 Share Posted March 16, 2012 I have no idea if this is possible or not, but I've got a form that searches a DB for a record. If that record is found, it displays a form that people can edit the record. Now, if that person wants to change (for example) 1 record out of 16 called "status" from "lost" to "found" but leave all the rest as they are, how would I go about this? Basically, I need to check all the fields ON SUBMIT if they're different from the original values in the DB and only update if they are. Any help would be appreciated. Cheers, Dave Quote Link to comment https://forums.phpfreaks.com/topic/259046-update-table-only-if-the-value-has-changed/ Share on other sites More sharing options...
Muddy_Funster Posted March 16, 2012 Share Posted March 16, 2012 you could check your form values against the returned values and build your update query to refference only the fields that don't match the original database return. if you are doing this over multiple pages you would want to put your database return into a session variable for easier access on the second page. Quote Link to comment https://forums.phpfreaks.com/topic/259046-update-table-only-if-the-value-has-changed/#findComment-1327995 Share on other sites More sharing options...
jcbones Posted March 16, 2012 Share Posted March 16, 2012 If you are using MySQL just pass it, the database will only update if the values are different. It's smart like that. Quote Link to comment https://forums.phpfreaks.com/topic/259046-update-table-only-if-the-value-has-changed/#findComment-1328122 Share on other sites More sharing options...
scootstah Posted March 16, 2012 Share Posted March 16, 2012 If you are using MySQL just pass it, the database will only update if the values are different. It's smart like that. Yeah, this. Otherwise you're going to have to do something which is inefficient and nonsensical. Quote Link to comment https://forums.phpfreaks.com/topic/259046-update-table-only-if-the-value-has-changed/#findComment-1328125 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.