Mega Code Archive

 
Categories / Php / Code Snippets
 

Delete data from a MySQL database

<?php /* * 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 codedb_connect(); $query = "DELETE FROM tablename WHERE id = ('$id')"; $result = mysql_query($query); echo "The data has been deleted."; ?>