Jump to content

Is it possible to display database contents randomly on radio button


krishnadaspc

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>

 

 

Archived

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

×
×
  • 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.