爲什麼不能我總結的收入中的代碼只是顯示在總營收最後:如何正確總結?總結在HTML中使用PHP
<table border="1">
<tr>
<th>Date</th>
<th>Route</th>
<th>Destination</th>
<th>Van No.</th>
<th>Waybill No.</th>
<th>Charge Invoice</th>
<th>Revenue</th>
<th>Strip/Stuff</th>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_PK['delivery_details_date']; ?></td>
<td><?php echo $row_PK['delivery_details_route']; ?></td>
<td><?php echo $row_PK['delivery_details_destination']; ?></td>
<td><?php echo $row_PK['delivery_details_van_no']; ?></td>
<td><?php echo $row_PK['delivery_details_waybill_no']; ?></td>
<td><?php echo $row_PK['delivery_details_charge_invoice']; ?></td>
<td><?php echo $row_PK['delivery_details_revenue']; ?></td>
<td><?php echo $row_PK['delivery_details_strip_stuff']; ?></td>
<?php $revenue = $row_PK['delivery_details_revenue'];
$sum += $revenue;?>
</tr>
<?php } while ($row_PK = mysql_fetch_assoc($PK));?>
</table>
TOTAL: <?php echo $revenue; ?> <br/>
TOTAL只顯示最後記錄的收入,它並沒有全部添加爲什麼?
你不是明明輸出的總和。 '$ sum + = $收入;'你的代碼?你知道它做了什麼嗎?然後再看看最後一個'echo'。 – mario
除非您的$ row_PK變量設置在循環之前,否則您不能通過'do ... while'循環遍歷結果集,而這看起來不像循環。 – nickb