This is my code that I am using to try and calculate the sum of “amountReceived” column. The total for invID ’95’ should = 312, but for some reason it is only = 300. I am not sure what the issue is. (please see the DB images below).
$sql = mysql_query("SELECT amountReceived FROM payments WHERE invID='".$id."'");
$result = mysql_fetch_array($sql);
$totalPayment = array_sum($result);
$balanceDue = $invoiceTotal - $totalPayment;


well the mysql_fetch_array($sql) returns an array containing all “columns” of one row you fetched, means you get an e.g. array(‘amountReceived’=>150)
this should work:
this is just a php side description of the problem, if you want to be more efficient, use sel‘s version 😉