I assume that you arent using laravel?
Do you mean that every user can delete their own booking? Cause as I can see from you code, you just check if there is a booking by that user and show a delete button. That seems correct I would assume?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello, I am creating a booking system and I get stuck on this issue when the user book for an appointment on a doctor he/she can cancel there appointment and am using this code for that
private function bookedCell($date)
{
$db = DB();
$user_id = $_SESSION['id'];
// check if this user made the booking
$query = $db->prepare('SELECT id FROM bookings WHERE student_id = :id');
$query->bindParam('id', $user_id, PDO::PARAM_INT);
$query->execute();
if ($query->rowCount() > 0) {
$res = $query->fetchAll();
return '<div class="booked">' . $this->deleteForm($this->bookingId($date)) . '</div>';
}
}
I want to show the cancel button to the users who made the booking but now the delete button is shown for everyone
Please or to participate in this conversation.