Hi,
I am creating a quiz administration system. Users are currently able to create their own mutli-choice quizzes and I can display the quizzes the onl troble is I can't save the data once they have taken a quiz!!!
The problem is the data is displaed as below:
The quiz name
Question
answer
answer
answer
answer
Question
etc
However this is displaed dynamically from the code below:
// File name: Take quiz.php
// Last updated: 23/03/03
?>
<?
include "header_student_login.php";
?>
<html>
<head>
<title>Students welcome to Quizzical</title>
<style type="text/css">
<!--
p { font-family: Arial, Helvetica, sans-serif; font-size: 12px}
a { color: #003366}
a:hover { color: #0066CC}
-->
</style>
</head>
<body>
<?
mysql_select_db("kism9cls") or
die ("Could not select database");
$result3=mysql_query("select from users where useridentifier=$user")
or die ("cant do it");
while($query_data3=mysql_fetch_row($result3))
{
$result = mysql_query("SELECT FROM quiz WHERE quizno =$useridentifier")or die ("cant do it");
while($query_data=mysql_fetch_row($result)) {
echo "<H2><CENTER>",$query_data[1],"</h2></CENTER>
<font face='arial' size 2>",$query_data3[1]," is taking: ",$query_data[2],"<br><br></font>";
$result1 = mysql_query("SELECT * FROM questions WHERE questions.quizno = $useridentifier")or die ("cant do it");
while($query_data1=mysql_fetch_row($result1)) {
echo "<font face='arial' size 2><br>",$query_data1[1],"</font><br>";
$result2 = mysql_query("SELECT * FROM answers WHERE answers.questionno = $query_data1[0]")or die ("cant do it");
while($query_data2=mysql_fetch_row($result2)) {
echo "<font face='arial' size 2>",$query_data2[1],"<input type=checkbox name=",$query_data2[0]," value=$result2>";
echo "<br>";
echo "<form method=post action='create_entry_sanswers.php?quiznno=".$query_data[0]."&questionno=".$query_data1[0]."&answerno=",$query_data2[0],"&user=".$query_data3[0]."'>";
}
echo "<input type=submit name=submit value='Register'>";
}}}
?>
<br>
<br>
<table>
<td></td>
<td colspan=2 align=center>
<input type=submit name=submit value="Register">
<input type=reset name=reset value="Clear">
</td></tr>
</table></form>
</body>
</html>
<?
include "footer.php";
?>
I use a second file to save the data
// File name: Create_entry_answers.php
// Last updated: 23/03/03
?>
<?
include "header_testsetter_login.php";
include "db_fns.php";
?>
<style type="text/css">
<!--
p { font-family: Arial, Helvetica, sans-serif; font-size: 14px}
a { color: #003366}
a:hover { color: #0066CC}
-->
</style>
<?php
mysql_select_db("kism9cls") or
dir ("Could not select database");
if ($submit == "Register")
{
$query = "insert into results
(quizno, questionno, answerno, useridentifier) values ('$quiznno', '$questionno', '$answerno', '$user')";
mysql_query($query) or
die (mysql_error());
}
?>
<br>
<center>
<br><br>
<p>Question Successfully added to quiz</p>
<br>
<FONT FACE="arial" SIZE=2><A HREF="Existing quiz page 1.php?page=Existing Quiz">View Another Quiz</A></FONT>
</body></html>
<br>
<?
include "footer.php";
?>
On testing the scripts only one line of data is saving. I would expect one for each result (e.g. each question answered). The useridentifier and quizno are saving corerectl however the questionno and answerno is simply saving the first row of data returned!!!
Please help!!! This my final year project!!
Claire