Please i need your help. I’m performing SUM() on a column for course_unit, but i want it to omit a certain condition and then continue the loop. Example: course that have a grade of AR should be omitted from the loop, then continue.
Thanks for the help and patience. I most appreciate it.
Thanks
Query4 is used to generate some rows of course_unit and Score
$query4 = mysql_query("SELECT c.course_unit, m.score
FROM maintable AS m
INNER JOIN students AS s ON
m.matric_no = s.matric_no
INNER JOIN courses AS c ON
m.course_code = c.course_code
WHERE m.matric_no = '".$matric_no."'
AND m.level = '".$level."'")
or die (mysql_error());
Query3 is used for the summation of the course_units
$query3 = mysql_query("SELECT SUM(c.
course_unit) AS 'TOTAL'
FROM maintable AS m
INNER JOIN students AS s ON
m.matric_no = s.matric_no
INNER JOIN courses AS c ON
m.course_code = c.course_code
WHERE m.matric_no = '".$matric_no."'
AND m.level = '".$level."'")
or die (mysql_error());
Grades in Respect to Score
while ($row8 = mysql_fetch_assoc($query8)) {
if ($row8['score'] >= 70) {
$grade = 'A';
}
elseif ($row8['score'] >= 60) {
$grade = 'B';
}elseif ($row8['score'] >= 50) {
$grade = 'C';
}elseif ($row8['score'] >= 45) {
$grade = 'D';
}elseif($row8['score'] >= 40) {
$grade = 'E';
}elseif($row8['score'] >= 0) &&
($row8['score'] < 40){
$grade = 'F';
}else{
$grade = 'AR';
}
}
Calculation of the Grade Point
$grade_point = 0;
while ($row4 = mysql_fetch_assoc($query4)) {
if ($row4['score'] >= 70) {
$score = 5;
}
elseif ($row4['score'] >= 60) {
$score = 4;
}elseif ($row4['score'] >= 50) {
$score = 3;
}elseif ($row4['score'] >= 45) {
$score = 2;
}elseif($row4['score'] >= 40) {
$score = 1;
}else{
$score = 0;
}
$grade_point += $score * $row4['course_unit'];
}
QUESTION UPDATE
If the loop breaks at
$grade == 'AR'
Does the course having that grade gets it’s course_unit calculated in
SUM() ?
How about this: