我正在使用以下代码从数据库中获取数据。当我插入所有列值时,它显示我的输出正确。例如,我为' Hip'插入NULL值。所以它没有以表格形式显示。
请提前帮助我,谢谢!
$sizeArray = explode(',', $rows['sizes']);
$bustArray = explode(',', $rows['bust']);
$hipArray = explode(',', $rows['hip']);
$lengthArray = explode(',', $rows['length']);
$lengthArraybottom = explode(',', $rows['lengthbottom']);
$shoulderArray = explode(',', $rows['shoulder']);
foreach ($sizeArray as $key => $value) {
foreach ($bustArray as $bkey => $bvalue) {
foreach ($waistArray as $Wkey => $Wvalue) {
foreach ($hipArray as $hkey => $hvalue) {
foreach ($lengthArray as $lkey => $lvalue) {
foreach ($lengthArraybottom as $lkeybottom => $lbottomvalue) {
foreach ($shoulderArray as $skey => $svalue) {
if ($key == $bkey && $bkey == $Wkey && $Wkey == $hkey && $hkey == $lkey && $lkey == $lkeybottom && $lkeybottom == $skey) {
echo '<tr><td>' . $value . '</td>';
echo '<td>' . $bvalue . '</td>';
echo '<td>' . Wvalue . '</td>';
echo '<td>' . $hvalue . '</td>';
echo '<td>' . $lvalue . '</td>';
echo '<td>' . $lbottomvalue . '</td>';
echo '<td>' . $svalue . '</td></tr>';
}
}
}
}
}
}
}
}
答案 0 :(得分:0)
<table class="data-table">
<caption class="title">Sales Data of Electronic Division</caption>
<thead>
<tr>
<th>NO</th>
<th>CUSTOMER</th>
<th>ITEM</th>
<th>DATE</th>
<th>AMOUNT</th>
</tr>
</thead>
<tbody>
<?php
$no = 1;
$total = 0;
while ($row = mysqli_fetch_array($query))
{
$amount = $row['amount'] == 0 ? '' : number_format($row['amount']);
echo '<tr>
<td>'.$no.'</td>
<td>'.$row['name'].'</td>
<td>'.$row['item'].'</td>
<td>'. date('F d, Y', strtotime($row['date'])) . '</td>
<td>'.$amount.'</td>
</tr>';
$total += $row['amount'];
$no++;
}?>
</tbody>
<tfoot>
<tr>
<th colspan="4">TOTAL</th>
<th><?=number_format($total)?></th>
</tr>
</tfoot>
</table>
参考:http://webdevzoom.com/display-mysql-data-html-5-table-using-php/