【发布时间】:2016-08-07 16:52:42
【问题描述】:
在表格中,您可以看到第二个项目 id 1002 有两个条目。我想将 colspan 添加到该项目的第 1 列和第 3 列。
<table>
<tr>
<th>Item ID</th>
<th>Item Color</th>
<th>Customer</th>
</tr>
<?php
$sql = mysqi_query($con,"select * from item_table");
while($row = mysqli_fetch_array($sql)){
?>
<tr>
<td><?=$row['item_id'];?></td>
<td><?=$row['item_color'];?></td>
<td>
<select>
<?php
$sql_cust = mysqli_query($con,"select * from customer_tbl");
while($row_cust = mysqli_fetch_array()){
if($row['customer_id'] == $row_cust['customer_id']){
echo "<option selected='selected' >".$row['customer_name']."</option>";
}else{
echo "<option>".$row['customer_name']."</option>";
}
<?php
}
?>
</select>
</td>
</tr>
<?php
}
?>
</table>
但它以正常方式打印,我不知道如何在循环中添加行跨度..请提出一些逻辑来解决它的赞赏。
【问题讨论】:
标签: php html-table