Updating Data In MySQL Database Using PHP

So far we have seen the writing and reading methods in the database. Now we will see the update process.See the following example:

Often it is necessary to change the data you have in your database. Let's say that Peggy (from our example) came in for a visit on her 7th birthday and we want to overwrite her old data with her new data. If you are using phpMyAdmin you can do this by clicking your database on the left (in our case "people") and then choosing "Browse" on the right. Next to Peggy's name you will see a pencil icon, this means EDIT. Click on the pencil. You can now update her information as shown (see above.)

You can also do this through the query window or command line. You have to be very careful when updating records this way and double check your syntax, as it is very easy to inadvertently overwrite several records.


UPDATE people SET age = 7, date = "2006-06-02 16:21:00", height = 1.22 WHERE name = "Peggy"

0 Responses to "Updating Data In MySQL Database Using PHP"