Below is my code and for some reason it's not giving me the SUM. This always returns 0. Why doesn't it work?
I've used if ($totSubmits==''){
to avoid blank fields in my database.
I also tried removing AS due_fees
and using $dueAmont = $result[0]
, but no luck though.
$sql= "SELECT SUM(dueFees) AS due_fees FROM coursePayments WHERE studentId = $student";
$stmt = $c->prepare($sql);
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_NUM);
$dueAmont = $result['due_fees'];
if ($dueAmont==""){
$dueAmont = '0';
}
echo $student." due amount ".$dueAmont;