hello people i basically i need some information ive got a booking website which allows users to book a hotel room but once they book the room i dont want that room available to anybody else, im using Mysql databse linked to php, in the database i got a colum called booked which has all rows set to 0, but when the user books that row that 0 should change to 1, so the 1 bookings dont get displayed again how i can do this??

This isn't really an answer to your question, but maybe a more efficient / easier way to do it.

Why don't you do a use a sub-select to get the available rooms?

IE:

$sql = "SELECT * FROM tb__rooms r
           WHERE room_id NOT IN (SELECT room_id FROM tb__bookings b
                              WHERE startDate'".$bookingDate."' BETWEEN startDate AND endDate)"

Obviously change $bookingDate to the date that you want to book, or change the where statement to choose a range of dates.

This will select All of the rooms that are NOT booked between startDate and endDate

You could use the following:

$query = "UPDATE rooms SET room_available = '1' WHERE room_id = '$the_booked_room_id'";
$result = mysql_query($query);

Just a simple update will do the trick!!

This question has already been answered. Start a new discussion instead.