Delete data from a MySQL database

Delete data from a MySQL database
Description

How to remove and erase stored information from a MySQL database table.
The code





/*

* Change the first line to whatever

* you use to connect to the database.

*

* Change tablename to the name of your

* database table.

*

* This example would delete a row from

* a table based on the id of the row.

* You can change this to whatever you

* want.

*/



// Your database connection code

db_connect();



$query = "DELETE FROM tablename WHERE id = ('$id')";



$result = mysql_query($query);



echo "The data has been deleted.";



?>

Posted in |