Process of the mutiple question - php

php

#1

im currently working on my mutiple question quiz process that can auto generate my problem is i dont how to create the process of finding the correct answer and also showing which one is wrong asnwer i also create database for the quiz, anyone can help me with the process of the quiz? im really new in php, my database is.. and my code for the mcq is down below


> <?php
> include "checklogin.php";

> $query1 = mysql_query("SELECT * FROM `mcq_questions` WHERE q_id >=0 AND q_id <=3 order by rand() limit 1");
> $query2 = mysql_query("SELECT * FROM `mcq_questions` WHERE q_id >=4 AND q_id <=6 order by rand() limit 1");
> $query3 = mysql_query("SELECT * FROM `mcq_questions` WHERE q_id >=7 AND q_id <=9 order by rand() limit 1");
> $query4 = mysql_query("SELECT * FROM `mcq_questions` WHERE q_id >=10 AND q_id <=12 order by rand() limit 1");
> $query5 = mysql_query("SELECT * FROM `mcq_questions` WHERE q_id >=13 AND q_id <=15 order by rand() limit 1");
> $query6 = mysql_query("SELECT * FROM `mcq_questions` WHERE q_id >=16 AND q_id <=18 order by rand() limit 1");
> $query7 = mysql_query("SELECT * FROM `mcq_questions` WHERE q_id >=19 AND q_id <=21 order by rand() limit 1");
> $query8 = mysql_query("SELECT * FROM `mcq_questions` WHERE q_id >=22 AND q_id <=24 order by rand() limit 1");
> $query9 = mysql_query("SELECT * FROM `mcq_questions` WHERE q_id >=25 AND q_id <=27 order by rand() limit 1");
> $query10 = mysql_query("SELECT * FROM `mcq_questions` WHERE q_id >=28 AND q_id <=30 order by rand() limit 1");


> 	?>
> 	
> 	
> 	<form action ="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method ='POST'>
> 	
> 	<table border ='0' align ='left'>
> 	<tr><th>Examination Question</th></tr>
> 		
> 	<?php 
> 	//question 1
> 	if($row = mysql_fetch_array($query1)){ 
> 	echo "<tr><td>$row[q_detail]</td></tr>";
> 	echo "<tr><td><select name ='Question_1'>
> 	<option value='empty'></option>
> 	<option value='A'>$row[option_a]</option>
> 	<option value='B'>$row[option_b]</option>
> 	<option value='C'>$row[option_c]</option>
> 	td></tr>";}
> 	?>
> <?php
> 	
> 	
> 	//question 2
> 	if($row = mysql_fetch_array($query2)){ 
> 	echo "<tr><td>$row[q_detail]</td></tr>";
> 	echo "<tr><td><select name ='Question_1'>
> 	<option value='empty'></option>
> 	<option value='A'>$row[option_a]</option>
> 	<option value='B'>$row[option_b]</option>
> 	<option value='C'>$row[option_c]</option>
> 	td></tr>";}
> ?>
> <?php
> //question 3
> 	if($row = mysql_fetch_array($query3)){ 
> 	
> 	echo "<tr><td>$row[q_detail]</td></tr>";
> 	echo "<tr><td><select name ='Question_1'>
> 	<option value='empty'></option>
> 	<option value='A'>$row[option_a]</option>
> 	<option value='B'>$row[option_b]</option>
> 	<option value='C'>$row[option_c]</option>
> 	td></tr>";}

> ?>
> <?php
> //question 4
> 	if($row = mysql_fetch_array($query4)){ 
> 	echo "<tr><td>$row[q_detail]</td></tr>";
> 	echo "<tr><td><select name ='Question_1'>
> 	<option value='empty'></option>
> 	<option value='A'>$row[option_a]</option>
> 	<option value='B'>$row[option_b]</option>
> 	<option value='C'>$row[option_c]</option>
> 	td></tr>";}
> ?>
> <?php
> //question 5
> 	if($row = mysql_fetch_array($query5)){ 
> 	echo "<tr><td>$row[q_detail]</td></tr>";
> 	echo "<tr><td><select name ='Question_1'>
> 	<option value='empty'></option>
> 	<option value='A'>$row[option_a]</option>
> 	<option value='B'>$row[option_b]</option>
> 	<option value='C'>$row[option_c]</option>
> 	td></tr>";}
> ?>
> <?php
> //question 6
> 	if($row = mysql_fetch_array($query6)){ 
> 	echo "<tr><td>$row[q_detail]</td></tr>";
> 	echo "<tr><td><select name ='Question_1'>
> 	<option value='empty'></option>
> 	<option value='A'>$row[option_a]</option>
> 	<option value='B'>$row[option_b]</option>
> 	<option value='C'>$row[option_c]</option>
> 	td></tr>";}
> ?>
> <?php
> //question 5
> 	if($row = mysql_fetch_array($query7)){ 
> 	echo "<tr><td>$row[q_detail]</td></tr>";
> 	echo "<tr><td><select name ='Question_1'>
> 	<option value='empty'></option>
> 	<option value='A'>$row[option_a]</option>
> 	<option value='B'>$row[option_b]</option>
> 	<option value='C'>$row[option_c]</option>
> 	td></tr>";}
> ?>
> <?php
> //question 5
> 	if($row = mysql_fetch_array($query8)){ 
> 	echo "<tr><td>$row[q_detail]</td></tr>";
> 	echo "<tr><td><select name ='Question_1'>
> 	<option value='empty'></option>
> 	<option value='A'>$row[option_a]</option>
> 	<option value='B'>$row[option_b]</option>
> 	<option value='C'>$row[option_c]</option>
> 	td></tr>";}
> ?>
> <?php
> //question 5
> 	if($row = mysql_fetch_array($query9)){ 
> 	echo "<tr><td>$row[q_detail]</td></tr>";
> 	echo "<tr><td><select name ='Question_1'>
> 	<option value='empty'></option>
> 	<option value='A'>$row[option_a]</option>
> 	<option value='B'>$row[option_b]</option>
> 	<option value='C'>$row[option_c]</option>
> 	td></tr>";}
> ?>
> <?php
> //question 5
> 	if($row = mysql_fetch_array($query10)){ 
> 	echo "<tr><td>$row[q_detail]</td></tr>";
> 	echo "<tr><td><select name ='Question_1'>
> 	<option value='empty'></option>
> 	<option value='A'>$row[option_a]</option>
> 	<option value='B'>$row[option_b]</option>
> 	<option value='C'>$row[option_c]</option>
> 	td></tr>";}
> ?>

#2

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.