Good dat to everyone.!
Ive just so tired just to finished my thesis. Ive got problem in php summing up while looping and filtering. here is my code:
mysql_select_db($database_enamysqldb, $enamysqldb);
$query_recpayment = "SELECT amountpaid, username, SUM(amountpaid) FROM paymentsummary WHERE username = %s and foryear = %s and forlevel =%s", GetSQLValueString($colname_reclog, "text"), GetSQLValueString($_SESSION['MM_dyearnow']), GetSQLValueString($_SESSION['MM_enrolto']));
$recpayment = mysql_query($query_recpayment, $enamysqldb) or die(mysql_error());
$row_recpayment = mysql_fetch_assoc($recpayment);
$totalRows_recpayment = mysql_num_rows($recpayment);
$totalpayment=0;
while($row = mysql_fetch_array($recpayment)){
$totalpayment = $totalpayment + &row['SUM(amountpaid)'];
}
$_SESSION['MM_totalbills']=$totalpayment;
?>
I want to sum up all the value of the amountpaid field base on a filter of the where clause in mysql query. the sum then will be stored in a variable called $totalpayment, and after the sum is stored on that variable, i want to store it in a session variable as what the code looks above. But i think there something missing in my code. It fails to run, it results error unexpected.
Pls help.
Thank you. Peace on this mother earth.