当我尝试动态地将行跨度赋予<td>
(添加行跨度取决于数据库中的值)时,我得到的表格如下。出现了一个我不想要的额外列 (3::::3 ,4::::3)。如何阻止这个额外的列出现?
<?php
$time = array (
"06.00 - 07.00",
"07.00 - 08.00",
"08.00 - 09.00",
"09.00 - 10.00",
"10.00 - 11.00",
"11.00 - 12.00",
"12.00 - 01.00",
"01.00 - 02.00",
"02.00 - 03.00",
"03.00 - 04.00"
);
?>
<table border = "1">
<tr><th>time</th><th>room1</th><th>room2</th><th>room3</th></tr>
<?php
for ($i = 1; $i <= 10; $i++) {
?>
<tr>
<td><?php echo $time [$i - 1]; ?></td>
<?php
for ($j = 1; $j <= 3; $j++) {
?>
<td<?php if (($i == 2) && ($j == 3)) {echo ' rowspan="3"';} ?>><?php echo $i . "::::" . $j; ?></td>
<?php
}
?>
</tr>
<?php
}
?>
</table>