这是我用来尝试计算“amountReceived”列的总和的代码。invID '95' 的总数应该 = 312,但由于某种原因,它只有 = 300。我不确定问题出在哪里。(请参阅下面的数据库图像)。
$sql = mysql_query("SELECT amountReceived FROM payments WHERE invID='".$id."'");
$result = mysql_fetch_array($sql);
$totalPayment = array_sum($result);
$balanceDue = $invoiceTotal - $totalPayment;