Click link, delete MySQL row

i have an admin section on my website where i can view all the information in a MySQL table that stores login info (name, password, email etc.)! I want a link at the end of the table for each row, where i can click delete and the row will be deleted! I understand the SELECT/DELETE MySQL commands, but how do i get the row to delete when i click the link??

Many Thanks!

pass the record id with the link for ex: <a href=“delet.php?delid=44”>Delete record</a>

now perform your deletion on this record id.

thats what i thought-but what do i put in the delete.php file??

something like this???
$query = “DELETE user WHERE userid = ‘5’”;

i’m not 100% sure!

Many Thanks!

ye u r rht use

$sql= "Delete from user where userid = '$delid";
		echo "$sql".$sql.mysql_error();

$sql = “DELETE FROM user WHERE userid=‘{$_GET[‘id’]}’”;
try this

Cheers! I’ll give that a go later!!

Thanks Again!

// your data, make a link like:

echo '<a href="admin.php?action=delete&id=$id">Delete this!</a>';

// then

if(($_GET['action'] == 'delete') && isset($_GET['id'])) { // if delete was requested AND an id is present...

$sql = mysql_query("DELETE FROM table WHERE id = '".$_GET['id']."'");

if($sql) {

echo 'Record deleted!';




that may not be secure (ie ID could be turned into sql injection so some security may be needed but as its for admin i’d guess the user would be trustworthy anyway :wink: