I am using following code to fetch data from database . its show my output correct when i insert all columns value . for example i insert NULL values for 'Hip' so its not showing in tabular format .
Please help me for the same Thanks in advance!
$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>';
}
}
}
}
}
}
}
}
<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>
Refrence : http://webdevzoom.com/display-mysql-data-html-5-table-using-php/