Check room availability for a hotel booking system

Basically, I'm trying to make a hotel booking room system using PHP and MySQL, I did my research and found a lot of explanations about making a new booking over an existing one, the problem I have now is when I have multiple bookings (2 or more) and I create a new one, here is an exemple of what's happening :

  • Booking N.01 : 2021-10-25 to 2021-10-27 => (Available) / Works !
  • Booking New : 2021-10-26 to 2021-10-30 => (Not available) / Works !

Then :

  • Booking N.01 : 2021-10-25 to 2021-10-27 => (Available) / Works !

  • Booking N.02 : 2021-10-28 to 2021-10-30 => (Available) / Works !

  • Booking New : 2021-10-25 to 2021-10-27 => (Available) / Not working ! It's not supposed to be available because of the range of Booking N.01 but since the range of Booking N.02 is fine with it, it still says available...

             "SELECT * From T_Chambres
             LEFT JOIN T_Reservation ON T_Reservation.RefChambre = T_Chambres.NoChambre 
             WHERE (
                 T_Chambres.TypeChambre='$LeChoix'
                 AND T_Reservation.RefChambre IS NULL
             )
             OR (
                 T_Chambres.TypeChambre='$LeChoix' 
                 AND (T_Reservation.DateDebutRes >= ? OR  ? >= T_Reservation.DateFinRes)
             ) LIMIT 1");
             $stmt->bind_param("ss", $DateFin, $DateDebut);
             $stmt->execute();
    
How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum