Jump to content

Archived

This topic is now archived and is closed to further replies.

VAR5AN1

loop using form an sessions

Recommended Posts

we have initialised the session which does work...

We have initialised $ques = 1 so that it displays the first question stored from the database.

ok..the exact problem we encounter is that when the user clieck on next question button

it should remember the first question using session and the $ques should increment by 1 so that it goes to the next question using the same form and retriving the next question from the database..

the snippet code we have

$ques = 1;
$sql = "select * from question where QuestionID = $ques";

$rs=mysql_query($sql, $conn)
or die( "Could not execute query" );

do
{

while ($row = mysql_fetch_array($rs))
{
echo ("<form action=\"?=SID?\" method=\"post\" >");
echo ("Question $ques: " . $row["Question"]."<br><br>");
echo ("<input type=\"radio\" name=\"Answer\" value=>".$row["Answer1"]."<br>");
echo ("<input type=\"radio\" name=\"Answer\" value=>".$row["Answer2"]."<br>");
echo ("<input type=\"radio\" name=\"Answer\" value=>".$row["Answer3"]."<br>");
echo ("<input type=\"radio\" name=\"Answer\" value=>".$row["Answer4"]."<br><br>");
echo ("<input type=\"submit\" value=\"Next Question\"");
echo ("</form>");
}
$ques++;
}

i dont know if do loop will be appropriate for the loop

thank u 4 ur help

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.