2 questions regarding a quiz script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
minds_gifts
Forum Commoner
Posts: 63
Joined: Mon Feb 10, 2003 4:23 am

2 questions regarding a quiz script

Post by minds_gifts »

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

Code: Select all

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>";

}
evilcoder
Forum Contributor
Posts: 345
Joined: Tue Dec 17, 2002 5:37 am
Location: Sydney, Australia

Post by evilcoder »

its not accurate.. but you can make the flash thingy to last for exactly 20seconds, and then add this in your PHP:

Code: Select all

<?php
header( "Refresh: 20; url=quiz.php?question=2" );
?>
That will refresh the page serverside in 20 seconds, they can fool it by hitting the stop button on their browser.

Remember to change the query and page name to yours.
Post Reply