Page 1 of 1

Click HTML link and delete data from MySQL database using PHP

Posted: Sat Jan 26, 2019 12:52 pm
by shravaninetha
i have a table in my web page which displays all the info from mysql database and i want to provide delete link to delete info from database

Code: Select all

<a href="page.php?action=delete&id=$id">Delete</a>

Re: Click HTML link and delete data from MySQL database using PHP

Posted: Sat Jan 26, 2019 2:00 pm
by indhosting
you can use something like below

Code: Select all

<a href="page.php?action=delete&id=$id">Delete</a>

<?php

//database connection code goes here

if(($_GET['action'] == 'delete') && isset($_GET['id']))
		{
			$sql = "DELETE FROM webhowned WHERE OrderID = '".($_GET["id"])."'";
			if(mysqli_query($con,$sql))
			{
				echo 'Record deleted!';
				$show = 0;
			}
		}
?>

Re: Click HTML link and delete data from MySQL database using PHP

Posted: Mon Mar 18, 2019 12:49 pm
by risha
Really great info.

Re: Click HTML link and delete data from MySQL database using PHP

Posted: Tue Apr 02, 2019 1:49 pm
by hazel10
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??

Re: Click HTML link and delete data from MySQL database using PHP

Posted: Mon Jun 10, 2019 9:47 pm
by indhosting
hazel10 wrote:
Tue Apr 02, 2019 1:49 pm
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??

Hello hazel10,

Answer for your question is already stated and solved. Is there something different you need? If so please elaborate.