Click HTML link and delete data from MySQL database using PHP Topic is solved

HTML, PHP, CSS, Javascript, AJAX.............
shravaninetha
Posts: 4
Joined: Tue Jan 15, 2019 8:33 pm
Location: Hyderabad
Mood:
Age: 29

Click HTML link and delete data from MySQL database using PHP

Post by shravaninetha » Sat Jan 26, 2019 12:52 pm

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>

cuehosting
Posts: 8
Joined: Tue Jan 15, 2019 1:23 pm
Has thanked: 2 times
Been thanked: 7 times

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

Post by cuehosting » Sat Jan 26, 2019 2:00 pm

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;
			}
		}
?>

risha
Posts: 1
Joined: Mon Mar 18, 2019 12:47 pm

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

Post by risha » Mon Mar 18, 2019 12:49 pm

Really great info.

hazel10
Posts: 1
Joined: Tue Apr 02, 2019 1:47 pm

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

Post by hazel10 » 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??

cuehosting
Posts: 8
Joined: Tue Jan 15, 2019 1:23 pm
Has thanked: 2 times
Been thanked: 7 times

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

Post by cuehosting » Mon Jun 10, 2019 9:47 pm

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.

Post Reply Previous topicNext topic