我有一个关于学生排名的项目。样板学校一年做三次期末考试。我为每个期末考试创建了三个不同的表格(即 firsttermsar 为第一学期,secondtermsar 为第二学期,thirdtermsar 为第三学期)。
表结构是这样的:
id studentid matca1 matca2 matexam engca1 engca2 engexam
1 2 15 14 40 12 10 60
2 1 10 5 56 9 13 35
3 4 11 9 45 14 17 40
4 5 14 1 50 20 0 60
id 4 和 5 的学生在 class1,而学生 2 和 1 在 class2。我有一个单独的班级表格和学生资料信息的单独表格。
现在,我已经输出了结果单,但没有排名,看起来像这样
StudentId: 2 Full Name: Fawaz James Class: Pry 2 Overall Position: -
1stAss 2ndAss ExamScore Grade Position Rmks
Mark Obtainable 20 20 60
English 12 10 60 A - Excellent
Mathematics 15 14 40 B - V. Good
虽然我是初学者,而且我的代码一团糟,但它在下面提供。此外,我需要帮助计算基于班级的整体位置和基于班级的学科位置。请帮助我,因为我的项目取决于此以获得批准,并且在我被介绍给堆栈溢出之前的最后一周。
$query = "SELECT * FROM firsttermsars
WHERE studentID=$stuID AND year=\"$_SESSION[year]\""; #27
$result = mysql_query($query)
or die ("Couldn't execute query.");
while ($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
echo "<h2> First Term Stint Report Sheet for $namet during the SESSION $year</h2>";
echo "<table class='table1'>";
echo "<tr>";
echo "<td></td>";
echo "<td><b>1st Assessment</b></td><td><b>2nd Assessment</b></td>
<td><b>Mid Term<br />Exam</b></td><td><b>Mid Term<br />Total Score</b></td><td><b>Grade<br />Point</b></td></tr>";
echo "<tr> <td><b>Mark Obtainable</b></td><td><b>30</b></td><td><b>20</b></td><td><b>50</b></td><td><b>100</b></td><td><b>||=||</b></td></tr><tr>";
$tetal = $row['thirdengtest']+$row['thirdengexam']+$row['eng1'];
if ($tetal >="1") {
$q2 = "1";
$sq2 = "100";
echo "<td>English Language: </td>";
echo "<td>{$row['eng1']}</td><td>{$row['thirdengtest']}</td><td>{$row['thirdengexam']}</td> <td>";
$total1 = $row['thirdengtest']+$row['thirdengexam']+$row['eng1'];
echo $total1."</td><td>";
if ($total1>="75")
echo "A1";
elseif ($total1>="70")
echo "B2";
elseif ($total1>="65")
echo "B3";
elseif ($total1>="60")
echo "C4";
elseif ($total1>="55")
echo "C5";
elseif ($total1>="50")
echo "C6";
elseif ($total1>="45")
echo "D7";
elseif ($total1>="40")
echo "E8";
elseif ($total1>="1")
echo "F9";
elseif ($total1=="0")
echo "-";
else
echo "F";
echo "</td></tr>";
}
$tetal = $row['thirdmathtest']+$row['thirdmathexam']+$row['math1'];
if ($tetal >="1") {
$q3 = "1";
$sq3 = "100";
echo "<tr>";
echo "<td>Mathematics </td>";
echo "<td>{$row['math1']}</td><td>{$row['thirdmathtest']}</td> <td>{$row['thirdmathexam']}</td> <td>";
$total2 = $row['thirdmathtest']+$row['thirdmathexam']+$row['math1'];
echo $total2."</td><td>";
if ($total2>="75") echo "A1"; elseif ($total2>="70") echo "B2"; elseif ($total2>="65") echo "B3"; elseif ($total2>="60") echo "C4"; elseif ($total2>="55") echo "C5"; elseif ($total2>="50") echo "C6"; elseif ($total2>="45") echo "D7"; elseif ($total2>="40") echo "E8"; elseif ($total2>="1") echo "F9"; elseif ($total2=="0") echo "-"; else echo "F";
echo "</td></tr>";
}
?>
我希望你能像这样帮助我,希望并不复杂。我想添加输出的图片,但它抱怨我没有所需的声誉