Jump to content


Photo

loop using form an sessions


  • Please log in to reply
No replies to this topic

#1 VAR5AN1

VAR5AN1
  • Members
  • Pip
  • Newbie
  • 1 posts

Posted 13 April 2006 - 07:20 PM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users