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