$quiztotal = mysql_query('SELECT id,username,qname,quizpercentage FROM quiz');
echo '<table><tr><th>USERNAME</th>
<th>QUIZ NAME</th>
<th>PERCENTAGE</th>
<th>GRADE</th>
<th>POINTS</th></tr>';
while($row = mysql_fetch_array($quiztotal))
{
$username = $row['username'];
$qtotal = $row['quizpercentage'];
$defaultsetting = mysql_query('SELECT id,letter,percentage,points FROM default');
while($row = mysql_fetch_array($defaultsetting))
{
$letter = $row['letter'];
$percentage = $row['percentage'];
$points = $row['points'];
echo '<tr><td>'.$username.'</td>
<td>'.qtotal.'</td>';
echo 'td>';
if(qtotal == $percentage)
{
echo $letter;
}
echo '</td>';
echo '<td>';
if($letter)
{
echo $points;
}
echo '</td></tr>';
}
}
测验表
id username quizpercentage
1 35 66%
2 47 78%
3 53 90%
4 56 96%
5 4 45%
默认表
id letter percentage points
1 A >=85 4.00
2 B 80-84 3.67
3 C 83-75 2.65
4 D 74-55 2.00
这里 >=85 没有从 85% 到 100% 开始,而 80-84 是 80%、81% 和 84% 我如何正确匹配,比如假设用户得分 88%,我如何为每个用户打分,如果等级是 A/B/C/D 我也应该显示分数 我需要像这样的输出
USERNAME QUIZ NAME PERCENTAGE GRADE POINTS
35 TestSeries 85% A 4.00
47 TestSeries 70% C 2.65
53 preliminary 62% D 2.00