I am getting $final value from database and displaying in a table according to user. Now I have a value i.e., this is I was showing in the frontend
Userid Total Letter
36 45
5 67
78 90
42 82
12 57
Back End Code
$sql = mysql_query('SELECT userid, total FROM history');
echo '<table><th>Userid</th>
<th>Total</th>
<th>Grade</th>
while($row = mysql_fetch_array($sql))
{
echo '<tr><td>'.$row['userid'].'</td>
<td>'.$row['$total'].'</td>
$letter = mysql_query('SELECT score,letter FROM letter');
while($row = mysql_fetch_array($letter))
{
$score= $row['score'];
$letterp= $row['letter'];
switch($row['$total'])
{
case $row['$total'] == $score;
echo '<td>'.$letterp.'</td>';
break;
case $row['$total'] >= $score;
echo '<td>'.$letterp.'</td>';
break;
}
</tr>
}
I have a letter table
ID SCORE letter
1 100 A+
2 90 A-
3 80 B+
4 73 B-
5 65 C
6 55 D
7 45 E
8 0 F
Switch case is a sample I wrote here. I need to give condition like if userid scores 45 then I need to show letter E and if userid scores 67 then I need to show B-(b'coz the scorefield defines 65 to 54 is B-) . This is the exact requirement.