I am writing a hotel booking system. after lots of studying (including stack overflow) i wrote this sql to find out free rooms:
SELECT * FROM room WHERE room
I think this might get you started in the right direction...
SELECT R.* FROM room AS R LEFT OUTER JOIN bookings AS B USING (room_id) WHERE B.room_id IS NULL OR (B.checkout < '$check_in' AND B.checkin > '$check_out')