Hey I write this code for delete the selected check box values from the database. Yeah I know there are some example already here. But when I take look on them and tried to do as per they done in their question. still doesn't get the success. Can you guys help me with this query. When I click on the on the delete button the page is refresh and message display that records are delete successfully but after that not see any records delete from database
<html>
<head>
<title>
</title>
<meta name="" content="">
</head>
<body bgcolor="#05fa8c">
<form action="a.php" method="POST">
<table style="margin-top: 252px; font-size: larger; font-style: oblique;" align="center" bgcolor="#05fa8c">
<?php
include("config.php");
//$id = $_POST['id'];
$sbook = "SELECT * FROM `book`";
$rnq = mysqli_query($con,$sbook);
$count = mysqli_num_rows($rnq);
if(!$rnq)
{
print ("Error: %s\n ". mysqli_error($con));
}
echo "<table border=2 table style=margin-top: 252px; font-size: larger; font-style: oblique; bgcolor=#05fa8c>
<tr>
<td width=10% height= 10%><b>Book Name:</b></td>
<td width=10% height= 10%><b>Author Name:</b></td>
<td width=10% height= 10%><b>Publisher Name:</b></td>
<td width=10% height= 10%><b>Description</b></td>
<td width=3% height= 3% align='center'><b>#</b></td>
</tr>";
while($row = mysqli_fetch_array($rnq))
{
$rid = $row['id'];
$bname = $row['bname'];
$aname = $row['aname'];
$pname = $row['pname'];
$desc = $row['description'];
echo "<tr>
<td width=10% height= 10%><b>$bname</b></td>
<td width=10% height= 10%><b>$aname</b></td>
<td width=10% height= 10%><b>$pname</b></td>
<td width=10% height= 10%><b>$desc</b></td>";?>
<td align='center'><input type="checkbox" name="checkbox[<? echo $row['id']; ?>]" id="checkbox[<? echo $row['id']; ?>]" value="<? echo $row['id']; ?>"></td>
<?php }
echo "</table>";
echo "<input type='submit' name='delete' id='delete' value='Delete' >";
if(isset($_POST['delete'])){
foreach($_POST['checkbox'] as $del_id){
$del_id = (int)$del_id;
$sql = 'DELETE FROM `book` WHERE `id` = '.$del_id;
mysqli_query($con, $sql);
echo "Records delete successfully";
}
}
?>
</form>
</body>
</html>