<?php //first:connect to db include "conn.php"; //second? $bid = $_GET['id']; //create sql $sql="DELETE FROM badminton_court_booking WHERE Booking_ID= $bid"; mysqli_query($conn, $sql); //if unsuccessfully deleted...then if(mysqli_affected_rows($conn)<=0) { echo "<script>alert('Unable to delete data!');"; die ("window.location.href='booking_history.php';</script>"); } //successfully deleted then... echo "<script>alert('Your court booking has been cancelled!');</script>"; echo "<script>window.location.href='booking_history.php';</script>"; ?>