Hi. I am working on my Online Examination project in my web development subject but I am having a hard time to code how to go back to my previous page where I put session on it.
my online exam are categorize by subject then inside the subject there is a test name. FOr example:
Subject: Math
-Algebra
-Calculus
In admin side, if I want to view and edit all the question, the link will direct me to "view_subject.php" here's the code:
<?php
<h2>Subjects</h2>
<table width="1000" height="104" bordercolor="#666666" border="0">
<tr bordercolor="#666666">
<center>
<td width="100" height="33" bgcolor=" #d4d6f8" align="center"><b>Subject ID</b></td>
<td width="120" bgcolor=" #e1e2f7" align="center"><b>Subject Name</b></td>
<td width="88" bgcolor=" #e1e2f7" align="center"><b>VIEW TESTS</b></td>
</center>
</tr>
<?php
$result=mysql_query("SELECT count(subject_id) as subject_id FROM subject");
while($row=mysql_fetch_array($result))
{$subject_id=$row['subject_id'];}
$result=mysql_query("SELECT * from subject");
while($row=mysql_fetch_array($result))
{
?>
<tr>
<td height="35" align="center"><?php echo $row['subject_id']; ?></td>
<td ><?php echo $row['sub_name']; ?></td>
<td align="center"><a href="view_test.php?id=<?php echo $row['subject_id']?>" >VIEW</a></td>
</tr>
<?php
}
?>
When the admin will view the test under the particular subject, the admin just have to click the view.
<a href="view_test.php?id=<?php echo $row['subject_id']?>" >VIEW</a>
and then he will redirect to "view_test.php" where she will see the tests under the subject. here's the code:
<?php
<h2>List of Tests</h2>
<table width="1000" height="104" bordercolor="#666666" border="0">
<tr bordercolor="#666666">
<center>
<td width="100" height="33" bgcolor=" #d4d6f8" align="center"><b>Test ID</b></td>
<td width="120" bgcolor=" #e1e2f7" align="center"><b>Test Name</b></td>
<td width="120" bgcolor=" #e1e2f7" align="center"><b>View Question</b></td>
</center>
</tr>
<?php
$id=$_GET['id'];
$_SESSION['view_id']=$id;
$result=mysql_query("SELECT * FROM test WHERE subject_id='$id'");
while($row=mysql_fetch_array($result))
{
?>
<?php
$result=mysql_query("SELECT count(test_id) as test_id FROM test");
while($row=mysql_fetch_array($result))
{$test_id=$row['test_id'];}
$result=mysql_query("SELECT * FROM test WHERE subject_id LIKE '$id'");
while($row=mysql_fetch_array($result))
{
?>
<tr>
<td height="35" align="center"><?php echo $row['test_id']; ?></td>
<td ><?php echo $row['test_name']; ?></td>
<td align="center"><a href="view_test_ques.php?id=<?php echo $row['test_id']?>" >VIEW</a></td>
</tr>
<?php
}
}
?>
almost the same to view_subject.php. then when she click again the view , she will see the questions on the particular test. The code will redirect her to view_test_ques.php. here's the code:
<?php
<h2>Test Questions</h2>
<table width="1000" height="104" bordercolor="#666666" border="0">
<tr bordercolor="#666666">
<center>
<td width="80" height="33" bgcolor=" #d4d6f8" align="center"><b>Question id</b></td>
<td width="80" bgcolor=" #e1e2f7" align="center"><b>test id</b></td>
<td width="200" bgcolor="#d4d6f8" align="center"><b>question</b></td>
<td width="120" bgcolor=" #e1e2f7" align="center"><b>choice 1</b></td>
<td width="120" bgcolor=" #d4d6f8" align="center"><b>choice 2</b></td>
<td width="120" bgcolor=" #e1e2f7" align="center"><b>chocie 3</b></td>
<td width="120" bgcolor=" #e1e2f7" align="center"><b>choice 4</b></td>
<td width="60" bgcolor=" #d4d6f8" align="center"><b>answer</b></td>
<td width="60" bgcolor=" #e1e2f7" align="center"><b>edit</b></td>
<td width="80" bgcolor=" #e1e2f7" align="center"><b>status</b></td>
</center>
</tr>
<?php
$id=$_GET['id'];
$_SESSION['view_id']=$id;
$result=mysql_query("SELECT * FROM tblquestion WHERE test_id='$id'");
while($row=mysql_fetch_array($result))
{
?>
<?php
$result=mysql_query("SELECT count(ques_id) as ques_id FROM tblquestion");
while($row=mysql_fetch_array($result))
{$ques_id=$row['ques_id'];}
$result=mysql_query("SELECT * from tblquestion where test_id LIKE '$id'");
while($row=mysql_fetch_array($result))
{
?>
<tr>
<td height="35" align="center"><?php echo $row['ques_id']; ?></td>
<td align="center" ><?php echo $row['test_id']; ?></td>
<td ><?php echo $row['ques']; ?></td>
<td ><?php echo $row['choice1']; ?></td>
<td ><?php echo $row['choice2']; ?></td>
<td ><?php echo $row['choice3']; ?></td>
<td ><?php echo $row['choice4']; ?></td>
<td align="center"><?php echo $row['answer']; ?></td>
<td align="center"><a href="edit_ques.php?id=<?php echo $row['ques_id']?>" >EDIT</a></td>
<td align="center" ><a href="status.php?status=<?php echo $row['ques_id']?>"> <?php echo $row['status']; ?></td>
</tr>
<?php
}
}
?>
Now, I see all the question on a particular test. Now There's an edit link. I want to edit the particular question. I just have to click the "EDIT" which will redirect me to edit_ques.php. Once I already edit the questions. The program will prompt me a message box coz I put a javascript code.
<script type="text/javascript">
alert("Test Question has been Updated!");
window.location="view_test_ques.php";
</script>
Now, here's the problem. The message box will prompt me that the "Test question has been updated!". and it will redirect me to view_test_ques.php but when I click ok to the message box, the browser will show me that "Object Not Found".
I know that there's something wrong in my javascript code. Can you help me.? I know its about session. But I really don't know what to do.. Thank you..