I am trying to delete a displayed record using delete button but it is not deleting the record in mysqli database. Here is the code:
require_once('db_connect.php');
if(isset($_GET['del']))
{
$delete_id=$_GET['del'];
$delete_query = "DELETE FROM table_name WHERE id='$delete_id'";
$run=mysqli_query($mysqli,$delete_query);
if($run){
$output = "User has been deleted";
}
else{
$output = "Error deleting record";
}
}
and here is the button link code
<td><a href='?del=<?php echo $id ?>'><button class='btn btn-danger'>Delete this Record</button></a></td>
after deleting i get the right message that 'user has been deleted ' but the record in database exists and actually not deleted.
Please have a look and suggest a correction.
Thanks in advance.
0 comments:
Post a Comment