title: How to implement my student grading system inside a loop
body: <p>This part of my code is used to award a grade to a student score whenever i request a student semester result (Course Scores). But, only a particular grade is awarded to all the scores, most times the last result that was uploaded into the students database is awarded to all the scores. When i added  period to the grade i.e</p>
  
  <pre><code>  $grade .= 'A';
    $grade .= 'B';
    $grade .= 'C';
    $grade .= 'D';
    $grade .= 'E';
  </code></pre>
  
  <p>all the grades were repeated in each column. So assuming a particular student took 6 courses in a semester and had a total of</p>
  
  <pre><code>  3 A's , 2 B's , 1 C 
  </code></pre>
  
  <p>all the 6 grades were repeated on each row for the six courses.</p>
  
  <p>On the HTML Table i'm generating i have the following columns</p>
  
  <pre><code>   Course_code
     Course_title
     Course_unit
     Score
     Grade
  </code></pre>
  
  <p>Only the first four are from values that are already in the database, the last (grade), i'm generating whenever i want to request students semester result.</p>
  
  <pre><code>   while ($row8 = mysql_fetch_assoc               ($query8)) {
              if ($row8['score'] &gt;= 70) {
                $grade = 'A';
             }
              elseif ($row8['score'] &gt;= 60) {
              $grade = 'B';
              }elseif ($row8['score'] &gt;= 50) {
              $grade = 'C';
              }elseif ($row8['score'] &gt;= 45) {
              $grade = 'D';
              }elseif($row8['score'] &gt;= 40) {
              $grade = 'E';
              }else{
              $grade = 'F';
              }   
              }   
  </code></pre>
  
  <p>Query8</p>
  
  <pre><code>    $query8 = mysql_query("SELECT  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());
  </code></pre>
  
  <p>Table Structure</p>
  
  <pre><code>MAINTABLE: 
  score_id 
  matric_no 
  session
  semester_name 
  course_code 
  level         
  score 
  grade
  
  COURSES: 
  course_id 
  course_code 
  course_title 
  course_unit
  
   STUDENT 
   matric_no 
   first_name 
   last_name
   other_name 
   level
  </code></pre>
  
  <p>Thanks for your patience and help. I most appreciate it.</p>
  
  <p>Thanks. </p>