This code in the delete function is not working properly. The code seems fine and no error but doesn’t execute properly in the system I am making. Please help me with this issue. Thank in advance.
I tried checking the SQL query in the database but the integrated in PHP, it is not working.
Here is my code:
if (isset($_GET['delete_id'])) {
$delete_id = $_GET['delete_id'];
$delete_sql = "DELETE FROM employees WHERE employee_id = $delete_id";
$delete_result = mysqli_query($connect, $delete_sql);
if (!$delete_result) {
echo "<script>alert('Employee deletion failed.')</script>";
} else {
echo "<script>alert('Employee deleted successfully!')</script>";
}
echo "<script>window.location.href='employee_list.php'</script>";
}
<a href="employee_list.php?delete_id=<?php echo $row["employee_id"];?>" onClick="return confirm('Are you sure you want to delete?')"><i class="glyphicon glyphicon-trash" style="font- size:16px;color:red;"></i></a>