I am trying with online exam in php mysql when users logged in they have to get random question papers. I have created a table subject which stores subid,subject name and another table test which stores test id, subject id,test name etc.. When users logins he has to get different question papers when logged in.
In my code when user login's the test details are not displayed.. Here is the code
$result = mysql_query("select t.*,s.subname from test as t, subject as s where s.subid=t.subid and CURRENT_TIMESTAMP<t.testto and t.totalquestions=(select count(*) from question where testid=t.testid) and NOT EXISTS(select stdid,testid from studenttest where testid=t.testid and stdid=" . $_SESSION['stdid'] . ");");
if (mysql_num_rows($result) == 0) {
echo"<h3 style=\"color:#0000cc;text-align:center;\">Sorry...! For this moment, You have not Offered to take any tests.</h3>";
} else {
//editing components
?>
<table>
<tr>
<td> Test Name </td>
<td> Test Description </td>
<td> Subject Name </td>
<td> Duration </td>
<td> Test Code </td>
<td> Total Questions </td>
<td> Take Test </td>
</tr>
<?php
if(mt_rand(1,2)==2)
{
echo "<tr>";
echo "<td>" . htmlspecialchars_decode($r['testname'], ENT_QUOTES) . "</td><td >" . htmlspecialchars_decode($r['testdesc'], ENT_QUOTES) . "</td><td >" . htmlspecialchars_decode($r['subname'], ENT_QUOTES)
"</td><td>" . htmlspecialchars_decode($r['duration'], ENT_QUOTES) . "</td><td>" .$r['testcode']. "</td><td>" . htmlspecialchars_decode($r['totalquestions'], ENT_QUOTES) . "</td>"
. "<td><a title=\"Start Test\" href=\"stdtest.php?testcode=" . htmlspecialchars_decode($r['testname'], ENT_QUOTES) . "\"><img src=\"images/quiz-icon.png\" height=\"29\" width=\"28\" style=\"align:center\" alt=\"Start Test\" /></a></td></tr>";
}
?>
</table>
Aucun commentaire:
Enregistrer un commentaire