<table border="1" style="width: 100%;" class="table table-striped">
<tbody>
<tr>
<td style="background-color: #d2cfcf;" rowspan="2" align="center"><label>TIME</label></td>
<td style="background-color: #d2cfcf;" colspan="5" align="center"><label>
<?php
$date_ = date('Y-m-d');
echo $date_;
?></label></td>
</tr>
<tr style="background-color: #d2cfcf;" align="center">
<td>Bay 1</td>
<td>Bay 2</td>
<td>Bay 3</td>
<td>Bay 4</td>
<td>Bay 5</td>
</tr>
<!-- <tr align="center"> -->
<!-- <td style="background-color: #d2cfcf;">asd</td>
<td>asd</td>
<td>asd</td>
<td>asd</td>
<td>asd</td>
<td>asd</td> -->
<?php
require_once("db_connect.php");
$result = mysqli_query($conn, "SELECT * FROM tbl_accessories");
if($result->num_rows>0){
while($row = $result->fetch_assoc()){
echo "<tr align='center'>";
echo "<td style='background-color: #d2cfcf;'>".$row['time_']."</td>";
echo "<td>".$row['bay1']."</td>";
echo "<td>".$row['bay2']."</td>";
echo "<td>".$row['bay3']."</td>";
echo "<td>".$row['bay4']."</td>";
echo "<td rowspan='5'>".$row['bay5']."</td>";
echo "</tr>";
}
}
?>
</tr>
</tbody>
</table>
我正在尝试在最后一列上创建rowspan ...但是当“<td>
”在while()下时我发现它无法正常工作..这就是上面的代码结果。 THIS IS MY OUTPUT请帮我解决这个问题..谢谢。
答案 0 :(得分:0)
不应关闭循环外的最后一个tr,而应将其关闭。看来你已经有了这个想法,但是你已经评论过了。
答案 1 :(得分:0)
尝试以下代码为我工作
<table border="1" style="width: 100%;" class="table table-striped">
<tbody>
<tr>
<td style="background-color: #d2cfcf;" rowspan="2" align="center"><label>TIME</label></td>
<td style="background-color: #d2cfcf;" colspan="5" align="center"><label>
<?php
$date_ = date('Y-m-d');
echo $date_;
?></label></td>
</tr>
<tr style="background-color: #d2cfcf;" align="center">
<td>Bay 1</td>
<td>Bay 2</td>
<td>Bay 3</td>
<td>Bay 4</td>
<td>Bay 5</td>
</tr>
<?php
require_once("db_connect.php");
$result = mysqli_query($conn, "SELECT * FROM tbl_accessories");
if($result->num_rows>0){
while($row = $result->fetch_assoc()){
echo "<tr align='center'>";
echo "<td style='background-color: #d2cfcf;'>".$row['time_']."</td>";
echo "<td>".$row['bay1']."</td>";
echo "<td>".$row['bay2']."</td>";
echo "<td>".$row['bay3']."</td>";
echo "<td>".$row['bay4']."</td>";
echo "<td rowspan='5'>".$row['bay5']."</td>";
echo "</tr>";
}
}
?>
</tbody>
</table>