Click HTML link and delete data from MySQL database using PHP Topic is solved
-
- 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
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>
-
- 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
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
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??
-
- 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
hazel10 wrote: ↑Tue Apr 02, 2019 1:49 pmi 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.