View Full Version : online quiz query

swati soni
09-15-2009, 01:53 PM
I am at the first stage of creating a quiz.
I wish to know is it possible to click a button to proceed to the next question, with questions to be asked using for/while loop

I want to use

1. php as scripting language.
2. Mysql as database.
3. For each correct answer there should be increment of 1 in score.
4. all questions are multiple choice questions.

I have writen a code but its not working properly,which is given below
If u can suggest something it would be a great help

Thanks in advance

code which i have written is:-

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>



$host="localhost"; // Host name
$username="root"; // Mysql username
//$password=""; // Mysql password
$db_name="rounds"; // Database name
$tbl_name="round1"; // Table name

// Connect to server and select databse.
mysql_connect("$host", "$username")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$sql="SELECT id,question,a,b,c,d,ans FROM $tbl_name";


echo " ".mysql_result($res,$i,0);
echo " ".mysql_result($res,$i,1).'<br/>';

<form method="get" >
<input type="radio" name="RadioGroup1" value="<?php echo " ".mysql_result($res,$i,2);?>" />
<?php echo " ".mysql_result($res,$i,2);?></label>
<input type="radio" name="RadioGroup1" value="radio" />
<?php echo " ".mysql_result($res,$i,3);?></label>
<input type="radio" name="RadioGroup1" value="radio" />
<?php echo " ".mysql_result($res,$i,4);?></label>
<input type="radio" name="RadioGroup1" value="radio" />
<?php echo " ".mysql_result($res,$i,5);?></label>
if (isset($_POST['RadioGroup1'])) {
$selected_radio = $_POST['RadioGroup1'];
print $selected_radio;


<form id="form1" name="form1" method="post" >
<input type="submit" name="Submit" value="Finish" />

echo "$score";


09-15-2009, 03:28 PM
Read this:


EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum