So i was making a project and i wanted to make it so when admin clicked on the delete button a custom alert popups which have three buttons "Yes" and "No" so if admin clicks on the yes button the user get deleted and if he clicks on the no buttons the users doesn't get deleted and the list remains the same i can make it so a the js alert popups and get the job done but its to simple and i wanted to have a customized alert box so here is the code
<tbody>
<tr>
<td> <?php echo $value['0']; ?> </td>
<td> <?php echo $value['1']; ?> </td>
<td> <?php echo $value['2']; ?> </td>
<td> <?php echo $value['3']; ?> </td>
<td> <?php echo $value['4']; ?> </td>
<td><img src="./assets/img/<?php echo $value['5'];?>" width="150px"</td>
<td> <?php echo $value['6']; ?> </td>
<td> <?php echo $value['7']; ?> </td>
<td><a href="./updateUser.php" class="btn btn-success">Edit</a></td>
<td><a href="./users.php?id=<?php echo $value[0] ?>" onclick="confirmDelete()" class="btn btn-danger">Delete </a></td>
<script>
function confirmDelete() {
Swal.fire({
title: 'Are you sure you want to Delete this entry?',
showDenyButton: true,
showCancelButton: true,
confirmButtonText: 'Yes',
denyButtonText: `No`,
}).then((result) => {
/* Read more about isConfirmed, isDenied below */
if (result.isConfirmed) {
Swal.fire('Deleted!', '', 'success')
} else if (result.isDenied) {
Swal.fire('Deletion Was Cancelled', '', 'info')
}
})
}
</script>
</tr>
<?php if (isset($_GET["id"])) {
$id = $_GET["id"];
$query_remove = "DELETE FROM `users` WHERE `id` = $id";
mysqli_query($conn, $query_remove);
}
?>
</tbody>
this is the code,
p.s. i am using sweet alert 2 for cutom alerts.
and as mentioned above i tried this
<td><a href="./users.php?id=<?php echo $value[0] ?>" onclick="return confirm('are you sure you want to delete??')" class="btn btn-danger">Delete</a></td>
and it pops up a simple alert which i don't want so is there any way to do it?