I'm fairly new to all this and I'm putting together a site that will advise if a certain resource is free. So lets say there's twenty desks in the office, people can log into them when working on them so others can see what hotdesks are available when coming into the office.
I have a database called 'hotdesk, a table called 'booking' which contains colums 'Ref', 'Deskref', 'Booked', 'Name', 'From' and 'To'.
I have a form which updates the table appropriately when people log into these desks, the database is working fine. However I'm now trying to put together a query which will show which desks are free. This is the php query:
- Code: Select all
<?php if($row_Booking_System['Ref'] == "1" && $row_Booking_System['Booked'] == "Y") echo ": Not Available"; ?>
<?php if($row_Booking_System['Ref'] == "2" && $row_Booking_System['Booked'] == "Y") echo ": Not Available";
<?php if($row_Booking_System['Ref'] == "3" && $row_Booking_System['Booked'] == "Y") echo ": Not Available";
Etc.
The first query works, however the second doesnt, I've figured out that the data is only being returned for the first row in the table. So "1" can be found but eveyr other row is not returned. I put the following in and can confirm that it only returns the first row.
- Code: Select all
echo "HELLO: " . $row_Booking_System['Ref'];
My database connection info is:
- Code: Select all
<?php mysql_select_db($database_hotdesk, $hotdesk);
$query_Booking_System = "SELECT * FROM booking";
$Booking_System = mysql_query($query_Booking_System, $hotdesk) or die(mysql_error());
$row_Booking_System = mysql_fetch_assoc($Booking_System);
$totalRows_Booking_System = mysql_num_rows($Booking_System);
?>
Can anyone advise me what I've done wrong and why my query only works for the first row!?
Thank you very much in advance!


