Jump to content

loop using form an sessions


VAR5AN1

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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.