I have this code that perfoms a while loop on a two rowed table, whereby each row is multiplied by each others corresponding values. The problem i'm having is that $grade_point is showing all the multiplicated values for each row and adding them cummulatively. But i actually need the summation of the multiplicated values.
$grade_point = 0;
while ($row8 = mysql_fetch_assoc($query8)) {
if ($row8['score'] >= 70) {
$score = 5;
}elseif ($row8['score'] >= 60) {
$score = 4;
}elseif ($row8['score'] >= 50) {
$score = 3;
}elseif ($row8['score'] >= 45) {
$score = 2;
}elseif($row8['score'] >= 40) {
$score = 1;
}else{
$score = 0;
}
$grade_point += $score * $row['course_unit'];
echo "$grade_point";
}