1. HTML Source Code(Index.php)

<table border="1" cellspacing="10">
<tr>
<th>S. N.</th>
<th>Name</th>
<th>Email Id</th>
<th>Action.</th>
</tr>
<?php
$conn=mysqli_connect("localhost", "root", "", "testproject");
$query=mysqli_query($conn, "SELECT * FROM userdetails"); while($rows=mysqli_fetch_array($query)){
?>
<tr>
<td><?php echo $rows['id']; ?></td>
<td><?php echo $rows['name']; ?></td>
<td><?php echo $rows['email']; ?></td>
<td><a href="#" class="del" id=<?php echo $rows['id']; ?>">Delete</a></td>
</tr>
<?php } ?>
</table>

<script>
$(function () {
$('.del').click(function () {
var delid=$(this).attr("id"); var interval = 700;
$.ajax({
type: 'post',
url: 'delete.php,
data: { delid:delid },
success: function (data) {
if(data=='success'){
swal("Updated", "Password has been successfully updated", "success");
setTimeout(function() {
location.reload();
}, interval);
}
else{
swal("Updated Failed", "Password has been updated failed", "error");
}
}
});
return false;
});
});
</script>

2. PHP Source Code(delete.php)

<?php
$conn=mysqli_connect("localhost", "root", "", "testproject");
$id=$_GET["delid"];
$query=mysqli_query($conn, "DELETE FROM userdetails WHERE id='$id'");
if(query==true){
echo"success";
}
else{
echo"Failed";
}
?>