Php 如何卸下台面<;th>;缺口
我有6个表头和6个表数据,但是从图像中可以看到,表头有一个间隙,但是如何消除间隙? 有6个表头,但我需要7个表数据使其相等 如图所示: 为了更清晰,我将所有td和th背景设置为黑色(第6和第6 td): 编码:Php 如何卸下台面<;th>;缺口,php,css,html-table,tableheader,Php,Css,Html Table,Tableheader,我有6个表头和6个表数据,但是从图像中可以看到,表头有一个间隙,但是如何消除间隙? 有6个表头,但我需要7个表数据使其相等 如图所示: 为了更清晰,我将所有td和th背景设置为黑色(第6和第6 td): 编码: <table class="table table-bordered" style='padding: 20px 20px;display:table-header-group;table-layout: fixed;'> <tr>
<table class="table table-bordered" style='padding: 20px 20px;display:table-header-group;table-layout: fixed;'>
<tr>
<th>Date</th>
<th>Time</th>
<th>Product<th>
<th>Quantity</th>
<th>Price</th>
<th>Payment Method</th>
</tr>
<?php
while($row=mysqli_fetch_array($res)){
echo "<tr>";
echo "<td>"; echo $row['orderdate']; echo "</td>";
echo "<td>"; echo $row['ordertime']; echo "</td>";
/////////////////productname
echo "<td>";
echo "<table>";
while($row2=mysqli_fetch_array($res2)){
echo "<tr>";
echo "<th>"; echo $row2['listingname']; echo "</th>";
echo "</tr>";
}
echo "</table>";
echo "</td>";
echo "<td>"; echo "qty"; echo "</td>";
echo "<td>"; echo "price"; echo "</td>";
echo "</tr>";
}
?>
</table>
日期
时间
产品
量
价格
付款方式
在您的代码中,您声明了6列,但只感觉到其中的3列
因此,为了使其正确,您应该在最后一个td
中添加一个colspan
,如下代码所示:
<table class="table table-bordered" style='padding: 20px 20px;display:table-header-group;table-layout: fixed;'>
<tr>
<th>Date</th>
<th>Time</th>
<th>Product<th>
<th>Quantity</th>
<th>Price</th>
<th>Payment Method</th>
</tr>
<?php
while($row=mysqli_fetch_array($res)){
echo "<tr>";
echo "<td>"; echo $row['orderdate']; echo "</td>";
echo "<td>"; echo $row['ordertime']; echo "</td>";
/////////////////productname
echo "<td colspan='4'>";
echo "<table>";
while($row2=mysqli_fetch_array($res2)){
echo "<tr>";
echo "<th>"; echo $row2['listingname']; echo "</th>";
echo "</tr>";
}
echo "</table>";
echo "</td>";
echo "</tr>";
}
?>
</table>
日期
时间
产品
量
价格
付款方式
所以实际上我错过了产品末尾的第1个,感谢所有帮助我的人
<tr>
<th>Date</th>
<th>Time</th>
<th>Product</th>
<th>Quantity</th>
<th>Price</th>
<th>Payment Method</th>
</tr>
日期
时间
产品
量
价格
付款方式
实际上每行写3个tds…PHP通常用处不大。我们需要看到输出的HTML,最好是在演示中。所以实际上“product”中还有另一个表,只是product和quantity之间的表头有一个th的宽度