Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7641371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:54:18+00:00 2026-05-31T08:54:18+00:00

Please i need you help my script. I’m generating a new column, whereby a

  • 0

Please i need you help my script. I’m generating a new column, whereby a particular score is awarded a grade according to the score.
This query was used to obtain the scores from the main table.

$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());
    $number_cols1 = mysql_num_fields              ($query8);

I’ve being able to generate the grades accordingly, and a new column was added to the HTML Table , but i’m having a problem putting the heading to the new column that was added i.e “Grades”.
Also i’ve noticed that when i update a score and i re-run the results page the grades implementation does to take effect i.e if former score was “80” with grade “A”, and i downgrade to “33” with a grade of “F”, the script still outputs “A”, while the score has changed.

2) I’m also trying to copy all courses that have a grade of “F” into a seperate table. So the student will know courses he/she will have to retake. But my array implementation is not achieving this.

Thank you for you help.

               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';
              }else{
              $grade = 'F';
              }   }          

                echo "<table border = \"2\"                  cellspacing = \"1\" cellpadding =              \"2\"  bgcolor = MediumPurple class             =\"cambria\" >\n"; 
    echo "<tr align= \"center\">\n";

             echo "<th>";     //this echo out
         echo"s/n";        //the serial number
echo "</th>\n";  //heading for the table                      
     for ($i=0; $i<$number_cols; $i++) {                         
             echo "<th>" . mysql_field_name           ($query7, $i). "</th>\n";


                  }$serial = 0;                                                                                                 
               while ($row = mysql_fetch_row           ($query7)) {    
                  $serial++; 
                  echo "<tr align=center>\n"; 
                   echo"<td>";   
                  echo $serial;  
                  echo"</td>\n"; 

                  foreach ($row as $value)   
                   {    
                    echo "<td>$value</td>\n"; 
                   }      

                  echo "<td>";     
                  echo $grade ;        
                  echo "</td>\n";                        

                  }       
         for ($i=0; $i<$number_cols; $i++) {   
                  echo "</tr>\n"; 
                  echo "</table>"; 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T08:54:19+00:00Added an answer on May 31, 2026 at 8:54 am

    Please clean up that code, it’s a hideous ugly mess and almost impossible to read through.

    That being said, the problem is that you’re setting the letter grade BEFORE you fetch the individual grades. You seem to be using a query7 to fetch grades, but determine the score BEFORE that query is even run, so you output the same letter score for every grade fetched by query7.

    Look up HEREDOCs, they’ll help eliminate your bad case of ‘leaning toothpick syndrome’ – repeated echoes for output html is horrible for maintainability and legibility.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please I need help getting the exact md5 value of this python script in
I need some help with a LINQ query in VB.Net, please. I have this
I need some help with this please I can't get a handle on it.
Need some help, please. I have a line of horizontal thumbnails loaded as ONE
I need some help! Please. I am trying to develop a very very simple
I am getting a little confused and need some help please. Take these two
I need some with help with PowerShell, please. It should be pretty easy: I
Please help! I need to produce a Crystal Report with multiple data columns, but
Please help to the newbie in WPF! I need to build a TreeView with
I need to convert the function path::combine(path1, path2). Please help me if you have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.