Page 1 of 1
Keep MySQL Values the Same
Posted: Fri Jun 26, 2009 2:17 pm
by neex1233
Re: Keep MySQL Values the Same
Posted: Fri Jun 26, 2009 2:40 pm
by califdon
In your code, before you UPDATE the table with the new data, test each value returned from your Form, and build your UPDATE SQL statement to update ONLY the fields that are not blank. Be warned, though, that that prevents the user from deliberately blanking out a field.
Are you displaying the current data values in the HTML Form that is initially sent to the browser? You certainly should be, then the chance that a user will accidentally leave a field blank is reduced, and you shouldn't have to do anything special. Unless what you want to do is make it impossible for a user to blank out data that was previously entered. If that's the case, I don't see what value there is in doing that. Someone who wants to remove previous data could just enter "X" or something. You have to think about what it is you are trying to accomplish.
Re: Keep MySQL Values the Same
Posted: Fri Jun 26, 2009 2:51 pm
by neex1233
Ok, but how would I do that?
Re: Keep MySQL Values the Same
Posted: Fri Jun 26, 2009 3:08 pm
by califdon
Do what? Write the code? You haven't said what you are trying to accomplish. That's the first step. Then you have to plan it out on paper. What is being sent to the browser the first time? What is your data structure? There's a hundred questions that have to be answered before you try to write any code. And I certainly don't have time to write it for you.