Jump to content

Recommended Posts

I have a quiz program, it is working but it shows the options of the questions in the same order ie currently the correct answer of each of the question will be displayed as the last option only. Is there anyway to display the options randomly?. Am a newbie; This is my first post here and your suggestions are sincerely appreciated. Here is my code which shows the questions and answers from the DB.

mysql_select_db("quiz_k");
$exam="SELECT * FROM php";
$result=mysql_query($exam);
for($i=1;$i<=20;$i++)
{
while($row=mysql_fetch_assoc($result))
{
echo $row['id'].")";
$x=$row['id'];

echo $row['question']."<br>";
?>
<input type="radio"   required='required' name="<?php echo $row['id'] ?>" value="<?php echo $row['option1'] ?>">
<?php
echo $row['option1'].'<br>';
?>
<input type="radio" required='required' name="<?php echo $row['id'] ?>" value="<?php  echo $row['option2'] ?>">
<?php
echo $row['option2'].'<br>';
?>
<input type="radio" required='required' name="<?php echo $row['id'] ?>" value="<?php  echo $row['option3'] ?>">
<?php
echo $row['option3'].'<br>';
?>
<input type="radio"  required='required' name="<?php echo $row['id'] ?>" value="<?php  echo $row['answer'] ?>">
<?php
echo $row['answer'].'<br>';


}
}

 ?>
 <br>
 
<input type="submit" name="submit" value="submit" >





</form>

</html>

 

 

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.