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: 24
India

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>

User avatar
indhosting
Posts: 5
Joined: Tue Jan 15, 2019 1:23 pm
India

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

Post by indhosting » 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
India

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.

Post Reply Previous topicNext topic