I'm working on a website that contains a table with 12 columns that displays various information about students in each row. I'm trying to add a 13th column that displays either PASS
, FAIL
, or leaves it BLANK
if the student hasn't written the exam yet.
In my MSSQL database I have two tables. T1 (Students) contains various information about the student and has a keyId (primary key) which is what the website table is using to group rows together by student. Once the student wrote the exam, he is assigned a student number in the same table (if not it is NULL
). This student number is the primary key in the second table that has either a value of PASS
or FAIL
attached to it.
EDIT: The data PASS or FAIL in the second table is inserted through the website on another tab where the teacher inputs the student number and chooses either pass or fail.
The data type of the Status column (pass or fail) is enum(string) P & F.
<?php
$objMSSQL = new cMSSQL();
//[...]
for($i = 0; $i < $noOfRows; $i++)
$noOfRows = $objMSSQL->getAffectedRows();
//[...]
$examStatus = $objMSSQL->getTable("
SELECT *
FROM [Students]
INNER JOIN [Exams] ON Exams.studentNo = Students.studentNo
")
if ($examStatus[$i][Status] == 'PASS')
echo '<td width="80px"> PASS </td>';
elseif ($examStatus[$i][Status] == 'FAIL')
echo '<td width="80px"> FAIL </td>';
else
echo '<td width="80px"></td>';
?>
I've been searching endlessly for a solution and just cant figure out why it isn't displaying correctly on the website (it's displaying pass or fail seemingly randomly and leaving nothing blank).