krishnadaspc Posted March 18, 2013 Share Posted March 18, 2013 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> Quote Link to comment https://forums.phpfreaks.com/topic/275802-is-it-possible-to-display-database-contents-randomly-on-radio-button/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.