Hi,
I have created a database, a table and stored 3 questions in the table. I need to show the questions one by one to users. when first question is visible then while loop should wait until user click on submit button.

My Code is:

include("dbconnect.php");
$result=mysql_query("select * from English") or
          die (mysql_error());
while ($row  = mysql_fetch_array($result))
{
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>English Quiz</title>
    <meta name="GENERATOR" content="Created by Narayankumar">
    </head>
    <body bgcolor="#FFFFFF" text="#000000">
    <div id="bv_Text1" style="position:absolute;left:0px;top:0px;width:196px;height:32px;z-index:0" align="left">
    <font style="font-size:27px" color="#000000" face="Arial"><b>Engilsh Quiz:</b></font></div>

    <div id="bv_Text2" style="position:absolute;left:0px;top:52px;width:500px;height:16px;z-index:1" align="left">
    <font style="font-size:13px" color="#000000" face="Arial"><? echo $row['QN']; echo ". "; echo $row['Q']; ?></font></div>

    <form action="evalution.php" method='POST'>
    <input type="radio" id="RadioButton1"" name="Q" value="A" style="position:absolute;left:0px;top:78px;z-index:2">
    <input type="radio" id="RadioButton2"" name="Q" value="B" style="position:absolute;left:0px;top:110px;z-index:3">
    <input type="radio" id="RadioButton3"" name="Q" value="C" style="position:absolute;left:0px;top:142px;z-index:4">
    <input type="radio" id="RadioButton4"" name="Q" value="D" style="position:absolute;left:0px;top:175px;z-index:5">
    <input type="submit" name="submit" value="Submit" style="position:absolute;left:39px;top:216px;width:75px;height:24px;z-index:10">

    </form>

    <div id="bv_Text3" style="position:absolute;left:33px;top:78px;width:201px;height:16px;z-index:6" align="left">
    <font style="font-size:13px" color="#000000" face="Arial"><? echo $row['A']; ?></font></div>
    <div id="bv_Text4" style="position:absolute;left:33px;top:110px;width:201px;height:16px;z-index:7" align="left">
    <font style="font-size:13px" color="#000000" face="Arial"><? echo $row['B']; ?></font></div>
    <div id="bv_Text5" style="position:absolute;left:33px;top:142px;width:201px;height:16px;z-index:8" align="left">
    <font style="font-size:13px" color="#000000" face="Arial"><? echo $row['C']; ?></font></div>
    <div id="bv_Text6" style="position:absolute;left:33px;top:176px;width:201px;height:16px;z-index:9" align="left">
    <font style="font-size:13px" color="#000000" face="Arial"><? echo $row['D']; ?></font></div>
    </body>
    </html>
    <?
    sleep(10);
}
?>

Please help me what i need to change?

Recommended Answers

All 2 Replies

Looks like you are trying to use PHP as a client-side script, not possible. You will need to add Javascript or buttons to new pages to reload the questions as PHP is server-side and is compiled to HTML before being sent to the client.

Thanks for your reply.
please provide an example code of preparing quiz.
Questions should be showed one by one.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.