Help for a quiz

Hello All,

I m working on a quiz, obviously for the first time :confused:
I have created a database like:
ID Question OPTION1 OPTION2 OPTION3 Correct answer.

Currently i have 20 questions with options and correct answer.

I want to display only 10 questions randomly out of 20, each time without repetition.

The quiz be like, in the div one question will show at a time. Once a question is submitted, another will come into its place. Also, i dont want to store users answer. It will be compared regularly with each answer and total will be displayed at the end of quiz.

But i dont know how to achieve. I need some idea to achieve this please.

Thanks


```html
<?php
include_once("php_includes/db_conx.php");
$sql="SELECT * FROM iq LIMIT 1";
$query=mysqli_query($db_conx,$sql);

?>

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<style>
.iqtest{ width:75%; height:140px; border:#03C 2px solid; padding-top:10px; padding-bottom:10px; padding-left:8px; padding-right:9px; margin-top:15%; margin-left:8%;}
</style>
</head>

<body>
<?php
	while ($row = mysqli_fetch_array($query, MYSQLI_ASSOC)) {
		$db_question = $row["question"];
		$db_option1 = $row["option1"];
        $db_option2 = $row["option2"];
        $db_option3 = $row["option3"];
        $correctans = $row["answer"];

?>
<div class="iqtest">

<form>
Question:<?php echo $db_question;?><br/><br/>

<input type="radio" name="response" value="<?php echo $db_option1;?>"><?php echo $db_option1;?><br/>
<input type="radio" name="response" value="<?php echo $db_option2;?>"><?php echo $db_option2;?><br/>
<input type="radio" name="response" value="<?php echo $db_option3;?>"><?php echo $db_option3;?><br/>

</form>
<?php
		}
?>
</div>

</body>
</html>

To select ten random questions:


SELECT question FROM table_name
ORDER BY RAND()
LIMIT 10

This isn’t the most performant way, but by far the easiest to work with and understand, which I think you are more concerned about.

However, this will not resolve the other issues, which is having a new question drop into place every time a question is answered. For that, you will need to keep track of the question ID’s that are being displayed, that were already displayed, and were answered.

I am working on an idea only.

I have made some changes to code on display part, here it is.

<?php
include_once("php_includes/db_conx.php");
$sql="SELECT * FROM iq ";
$query=mysqli_query($db_conx,$sql);

?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<style>
.iqtest{ width:75%; height:140px; border:#03C 2px solid; padding-top:10px; padding-bottom:10px; padding-left:8px; padding-right:9px; margin-top:15%; margin-left:8%;}
</style>
</head>

<body>
<?php
 $i=1;
	while ($row = mysqli_fetch_array($query, MYSQLI_ASSOC)) {
		$db_question = $row["question"];
		$db_option1 = $row["option1"];
        $db_option2 = $row["option2"];
        $db_option3 = $row["option3"];
        $correctans = $row["answer"];
 		$id = $row["id"];
 
?>
<div class="iqtest">

<form method="post">
Question <?php echo $i;?>:<?php echo $db_question;?><br/><br/>

<input type="radio" name="response[<?php echo $id;?>]" value="<?php echo $db_option1;?>"><?php echo $db_option1;?><br/>
<input type="radio" name="response[<?php echo $id;?>]" value="<?php echo $db_option2;?>"><?php echo $db_option2;?><br/> 
<input type="radio" name="response[<?php echo $id;?>]" value="<?php echo $db_option3;?>"><?php echo $db_option3;?><br/>
<input type="submit" name="submit">
</form></div>

<?php
$i=$i+1;		}
?>

</body>
</html>

I have an idea and this much of code only