我有一个如下所示的声明,其中我需要在表格的末尾添加所有发票总额。我的老板想知道所有发票的月份总数。
$r = $mysqli->query("SELECT * FROM invoice WHERE parent_id = '0' ");
while ($row = $r->fetch_array(MYSQLI_ASSOC))
{
echo '<table>';
echo '<tr>';
echo '<td>' . $row['invoice_total'] . '</td>';
echo '</tr>';
}
echo '</table>';
答案 0 :(得分:0)
你可以这样做:
$r = $mysqli->query("SELECT * FROM invoice WHERE parent_id = '0' ");
$sum = 0;
while ($row = $r->fetch_array(MYSQLI_ASSOC))
{
echo '<table>';
echo '<tr>';
echo '<td>' . $row['invoice_total'] . '</td>';
$sum = $sum + $row['invoice_total'];
echo '</tr>';
}
echo '$sum';