How to overwrite / update a previous record automatically in mySQL?
I have a mysql database that receives the data from a php form that submits a unique user id, and 3 sports. I will likely be adding new fields (age etc) but the main thing I want to accomplish is if my users go through the form again (logged into to the same user id) and submit different information, how could I overwrite the old entry so I only have 1 record for the user?
hopefully this is possible one way or another !
use update…
"UPDATE usertable SET userid = 1234 WHERE userid = 4567"
This will update the row where userid is equal to 4567 to a new user id of 1234 on the table named "usertable".
use the "update" command.
the basic syntax of it is
UPDATE <sometable> SET <fieldname>=<value>, <anotherfieldname>=<value> WHERE <fieldname>=<some restriction>
remember to always use a Where clause otherwise it will update every row in your table…which is not what you want to happen