It is supposed to show up details of a room selected, but the first record in database is always displayed. The link is incorrect too..

http://test/action/roomDetail.php?roomID=

The value is missed...

ROOM:

 <table border="0">   
    <tr>
    <td>
    <p>
        <label for="room">選擇房間</label>
        <select name="roomID">
        <?php  
          do {
            printf('<option value="%s">%s</option>', $row_rsRoom['roomID'], $row_rsRoom['roomID']);
          } while ($row_rsRoom = mysql_fetch_assoc($rsRoom));
        ?>        
        </select>
    </p>
    </td>
    <td>   
    <?php printf('<a href="action/roomDetail.php?roomID=%s">詳情</a>',$row_rsRoom['roomID']);
    ?>
    </td>    
    </tr>  
    </table>

DETAILS:

<?php require_once('../../config/conn.php'); 
$roomID=$_GET['roomID'];
$sql="SELECT * FROM roomBooking where roomID = '$roomID'";
$rs=mysql_query($sql,$conn);
$row_rs = mysql_fetch_assoc($rs);
$count=mysql_num_rows($rs);
$roomID=$row_rs['roomID'];
$bookingDate=$row_rs['bookingDate'];
$startTime=$row_rs['startTime'];
$endTime=$row_rs['endTime'];
$numberOfPeople=$row_rs['numberOfPeople'];
?>
...
<h2>房間: <?php echo $roomID ?></h2>
    </header>
    <p>日期: <?php echo $bookingDate ?></p>
    <p>開始時間: <?php echo $startTime ?></p>
    <p>結束時間: <?php echo $endTime ?></p>
    <p>使用房間人數: <?php echo $numberOfPeople ?></p>
Member Avatar for Zagga

Hi,

After a very brief look, your link shows a href="action/roomDetail.php?roomID=%s"
What is %s and where is it being defined?

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.