PDA

View Full Version : 2 questions regarding a quiz script


chinni
05-11-2003, 11:06 AM
hello everybody,

I'm making a quiz application and right now i'm displaying all the questions from the table.To make it more attractive, I would like to display only one question at a time and click next button for the other questions.
Should i simpliy modify my sql st or anything else??
How can i do this one??

One more question:
Is that a possible to put a time bar(something which we see in flash), like say if the user does'nt answer a question say 20 sec's, it has to skip to the next question.

Many thanks



include("contentdb.php");

$display = mysql_query("SELECT * FROM $table ORDER BY id",$db);

if (!$submit) {


echo "<form method=post action=$PHP_SELF>";
echo "<table border=2>";

while ($row = mysql_fetch_array($display)) {

$id = $row["id"];
$question = $row["question"];
$opt1 = $row["opt1"];
$opt2 = $row["opt2"];
$opt3 = $row["opt3"];
$answer = $row["answer"];

echo "<tr>";
echo "<td rowspan=4 background=schumi.jpg></td>";
echo "<td><b>$question</b></td></tr>";
echo "<tr><td><input type=radio name=q$id value=\"$opt1\">$opt1</td></tr>";
echo "<tr><td><input type=radio name=q$id value=\"$opt2\">$opt2</td></tr>";
echo "<tr><td><input type=radio name=q$id value=\"$opt3\">$opt3</td></tr>";

}

echo "</table>";
echo "<input type='submit' value='See how you did' name='submit'>";
echo "</form>";

}

optimism_
05-11-2003, 12:32 PM
hi - about the second question.

You could have a simple, disabled text box to display a countdown, and use javascript to change the value of the box every second. You could then use JS to redirect the page to the next one after 20secs has elapsed.


<form name="count">
<input type="text" name="counterbox" size="2" value="20">
</form>


function doInit(){
//i cant remember if its enabled or disabled - try both
//prevent the user from changing the value
document.count.couterbox.enabled=false;

var count = document.count.counterbox.defaultValue;
doCount();
}
function doCount(){
setTimeOut("document.count.counterbox.value=count;", 0);
count = count -1;
if(count <= 0){
location="nextpage.php";
}
setTimeOut("doCount()", 1000);
}


does this look alright to you?