retrieve and display selected results
My code will print the table of student result. If previous screen selected 2 students, it will print 2 students' records. when display the tables, I can get everything correct except student's marks and grades. All tables print same results. Please advice. Thank you.
<?php
$getst = $_POST["select"];
$getcid = $_POST["cid"];
$getcyr = $_POST["cyr"];
$geteid = $_POST["eid"];
$getnum = $_POST['num'];
foreach ($getst as $getstid)
{
//get school name
$rs = mysql_query("select SC_NAME from EDUCATION.SCHOOL");
while ($newArray = mysql_fetch_array($rs))
{
$scname=$newArray['SC_NAME'];
}
// get exam name
$rs = mysql_query("select E_DESC from EDUCATION.EXAM where E_ID = '$geteid'");
while ($newArray = mysql_fetch_array($rs))
{
$edesc=$newArray['E_DESC'];
}
//get student, class, and teacher record
$rs = mysql_query("select STUDENT.ST_NAME, STUDENT.ST_BEH, CLASS.C_NAME, TEACHER.T_NAME from EDUCATION.STUDENT, EDUCATION.CLASS, EDUCATION.TEACHER where STUDENT.ST_ID = '$getstid' and STUDENT.C_ID = '$getcid' and CLASS.C_YR = '$getcyr' and CLASS.C_ID = STUDENT.C_ID and CLASS.T_ID = TEACHER.T_ID");
while ($newArray = mysql_fetch_array($rs))
{
$stname=$newArray['ST_NAME'];
$stbeh=$newArray['ST_BEH'];
$cname=$newArray['C_NAME'];
$tname=$newArray['T_NAME'];
}
$number=0;
// get subjects, marks, grade, total, average, post_class and post_std
$rs = mysql_query("select distinct SUBJECT.SUB_DESC, SUB_ACH.MARKS, SUB_ACH.GRADE, OV_ACH.* from EDUCATION.SUB_ACH, EDUCATION.OV_ACH, EDUCATION.SUBJECT where SUB_ACH.ST_ID = '$getstid' and SUB_ACH.E_ID = '$geteid' and SUB_ACH.C_YR = '$getcyr' and OV_ACH.ST_ID = '$getstid' and OV_ACH.E_ID = '$geteid' and OV_ACH.C_YR = '$getcyr' and SUBJECT.SUB_CODE = SUB_ACH.SUB_CODE");
while ($newArray = mysql_fetch_array($rs))
{
$subdesc[]=$newArray['SUB_DESC'];
$total=$newArray['TOTAL'];
$average=$newArray['AVERAGE'];
$postclass=$newArray['POST_CLASS'];
$poststd=$newArray['POST_STD'];
$marks[] = $newArray['MARKS'];
$grade[] = $newArray['GRADE'];
$number++;
}
$rs = mysql_query("select GRADE from education.scale where YEAR = '$getcyr' and MIN <= '$average' order by MIN desc limit 1");
while ($newArray = mysql_fetch_array($rs))
{
$avgGrade = $newArray['GRADE'];
}
?>
<table align="center" width="75%" border="1" cellspacing="0.3">
<tr>
<th colspan="6">
<?php
print "<BR>".$scname."<BR>";
print $edesc." RESULT SLIP<BR><BR>";
?>
</th>
</tr>
<tr>
<th>STUDENT NAME:</th>
<th colspan="2"><?php print $stname; ?></th>
<th>TEACHER:</th>
<th colspan="2"><?php print $tname; ?></th>
</tr>
<tr>
<th>STUDENT ID:</th>
<th colspan="2"><?php print $getstid; ?></th>
<th>CLASS ID:</th>
<th colspan="2"><?php print $cname; ?></th>
</tr>
<tr>
<td colspan="6"> </td>
</tr>
<tr>
<th width="17.5%">SUBJECT</th>
<th width="10%">MARKS</th>
<th width="10%">GRADE</th>
<th width="17.5%">SUBJECT</th>
<th width="10%">MARKS</th>
<th width="10%">GRADE</th>
</tr>
<?php
for ($loop=0; $loop<$number; $loop++)
{
print "<tr><th>".$subdesc["$loop"]."</th>";
print "<td align='center'>".$marks["$loop"]."</td>";
print "<td align='center'>".$grade["$loop"]."</td>";
$loop++;
print "<th>".$subdesc["$loop"]."</th>";
print "<td align='center'>".$marks["$loop"]."</td>";
print "<td align='center'>".$grade["$loop"]."</td></tr>";
}
?>
<tr>
<td colspan="6"> </td>
</tr>
<tr>
<th>TOTAL</th>
<td colspan="2" align="center"><?php print $total; ?></td>
<th>GRADE</th>
<td colspan="2" align="center"><?php print $avgGrade; ?></td>
</tr>
<tr>
<th>AVERAGE</th>
<td colspan="2" align="center"><?php print $average; ?></td>
<th>POSITION</th>
<td colspan="2" align="center"><?php print $postclass; ?></td>
</tr>
<tr>
<td colspan="6"> </td>
</tr>
<tr>
<th>REMARKS</th>
<td colspan="5"><?php print "<BR>".$stbeh."<BR><BR>"; ?></td>
</tr>
<tr>
<th><BR>TEACHER<BR>SIGNATURE<BR><BR></th>
<td> </td>
<th>HEADMASTER<BR>SIGNATURE
</th>
<td> </td>
<th>PARENTS<BR>SIGNATURE</th>
<td> </td>
</tr>
</table>
<br><br>
<?php
}
?>
|