So far you have learnt how to put information into your My SQL database, view the information in it and select which information you would like to view.In this part I will show you how to do the two final actions, updating your database and deleting records from it.There may be a requirement where the existing data in a My SQL table needs to be modified. This will modify any field value of any My SQL table.The following code block has a generic SQL syntax of the UPDATE command to modify the data in the My SQL table − The WHERE clause is very useful when you want to update the selected rows in a table.This makes it much more effective for an update script.
$id=$_GET['id']; $username="username"; $password="password"; $database="your_database"; mysql_connect(localhost,$username,$password); $query=" SELECT * FROM contacts WHERE id='$id'"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); $i=0; while ($i As you can see, this code will output a standard form, but instead of having blank boxes like on the form for inserting a new record, this one already has the current information from the database inserted into it.
Using this you can then create the update script, which will actually have two sections to it.
The first part of the update script uses the single record selection from last week but adds a little HTML to it to make it more useful.
For example, you should investigate which applications are using the table.
If the name of the table changes, so the application code that refers to the table name needs to be changed as well.