table roomBooking:

roomBookingID   roomID  bookingDate     startTime   endTime     glID    
numberOfPeople  staffID

table room:

roomID typeOfRoom roomState

php code:
<?php require_once('../config/conn.php'); 
$sql="SELECT * FROM roomBooking, room WHERE roomState='empty'";
$rs=mysql_query($sql,$conn);
$row_rs = mysql_fetch_assoc($rs);
$count=mysql_num_rows($rs);
?>

...

<table border="0">
    <?php do { ?>
    <tr>
    <td>
    <?php echo $row_rs['roomID']; ?>
    </td>  
      <td>
     <?php printf('<a href="action/roomDetail.php?roomID=%s">詳情</a>',$row_rs['roomID']);
    ?>
    </td>
    <td>
    <?php printf('<a href="BookingManagement.php?roomID=%s">預約</a>',$row_rs['roomID']);
    ?>
    </td>  
    </tr>
    <?php }while ($row_rs = mysql_fetch_assoc($rs));?>
    </table>

I want to list out all roomID in table roomBooking where roomState in table room is empty but the result is wrong.It's supposed to show 5 and 87 respectively.

If you don't put an effort into describing the problem no one will put an effort into solving it. What error message are you getting? It would also help if you used the code tags.

You need to connect room and roomBooking by a matching column. Post your table structures.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.