2
我有一個表,允許人們在一天和一天預訂,我無法弄清楚如何格式化表格,以便它在循環達到9後結束列(從10 :00至18:00)。如果有人能指出我應該在哪裏放置任何<td>
或<tr>
標籤或任何我非常感激的東西,這裏是我現在的代碼。For循環和表列/行
<table width="579" border="0">
<tr>
<th width="78" scope="col"> </th>
<th width="78" scope="col">Monday</th>
<th width="78" scope="col">Tuesday</th>
<th width="78" scope="col">Wednesday</th>
<th width="78" scope="col">Thursday</th>
<th width="78" scope="col">Friday</th>
<th width="78" scope="col">Saturday</th>
<th width="78" scope="col">Sunday</th>
</tr>
<?php
$days=array(
1 => 'Monday',
2 => 'Tuesday',
3 => 'Wednesday',
4 => 'Thursday',
5 => 'Friday',
6 => 'Saturday',
7 => 'Sunday'
);
for($i=10;$i <=18; $i++){
?>
<tr>
<th height="151" scope="row"><? echo $i; ?>:00</th>
<td id="book">
<?php
$statement = "SELECT *
FROM booking
WHERE time = $i
AND day = '$days[$d]'";
$booked = $db_link->query($statement) or die ($db_link->error);
if($booked->num_rows==0){
?><a href="booking.php?day=<? echo $days[$d]; ?>&t=<? echo $i; ?>&b=1">Book</a>
<?php
}else{ ?>
BOOKED
<?
}?>
</td>
</tr>
<? } ?>
</table>
你想讓結果表看起來像什麼?您可以使用代碼片段工具爲您的問題添加示例。 – dan08 2015-02-11 16:40:22