I have a list of mysql data entries on a webpage like:
1 name1 email1
2 name2 email2
3 name3 email3
ect.
How can I delete an entire row (id, name and email) from that database using a link so it will look like:
1 name1 email 1 - delete this (clicking on this link will delete this row)
I Googled around and found this:
http://www.totallyphp.co.uk/code/delete ... tabase.htm
Code: Select all
<?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 code
db_connect();
$query = "DELETE FROM tablename WHERE id = ('$id')";
$result = mysql_query($query);
echo "The data has been deleted.";
?> Anyone got some suggestions?
Thanks in advance!