Sir ,
The followoing code for open a question from database and user click
answer and click the next question but its not work
[PHP]
<?php
session_start() ;
if (!isset($_SESSI ON['count']))
$_SESSION['count'] = 1;
if (isset($_POST['submitted'])) {
$con = mysql_connect(" localhost","roo t","123456") ;
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db ("my_db", $con);
$sql="select * from quest where count = ".$_SESSION['count']."";
echo $sql;
$r=mysql_query( $sql);
if (!r)
{
die('Error: ' . mysql_error());
exit();
}
while($row = mysql_fetch_arr ay($r))
//while($_SESSION['count'] <<3)
{?>
<p style="color: #0000ff"><?php echo
$row['que'];?><table border='0'><tr> <td valign='top'><i nput
type='radio' name='quiz' value='4' /></td><td><?php echo
$row['op1'];?><br></td></tr><tr><td valign='top'><i nput
type='radio' name='quiz' value='3' /></td><td><?php echo
$row['op2'];?><br></td></tr><tr><td valign='top'><i nput
type='radio' name='quiz' value='2' /></td><td><?php echo
$row['op3'];?><br></td></tr><tr><td valign='top'><i nput
type='radio' name='quiz' value='1' /></td><td><?php echo
$row['op4'];?><br></td></tr></table><br></p></form>
<?php
$que=$_POST['que'];
$quiz=$_POST['quiz'];
$sql2="select answer from answerquest where que like ".$que." and
correctoption like ".$quiz."";
$run=mysql_quer y($sql2);
if(mysql_num_ro ws($run) == ""){
echo "wrong answer";
}else{
echo "right answer";
}
}
mysql_close($co n);
echo 'This is question no. '.$_SESSION['count'];
$_SESSION['count'] += 1;
}?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><ti tle>Questionnai re</title></head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="hidden" name="que" value="<?php=$r ow['que']?>">
<input type="submit" VALUE="Click here for the next question <?php
echo $_SESSION['count']; ?>" />
<input type="hidden" name="submitted " value="1" />
</form></body></html>
[/PHP]
sanjay
The followoing code for open a question from database and user click
answer and click the next question but its not work
[PHP]
<?php
session_start() ;
if (!isset($_SESSI ON['count']))
$_SESSION['count'] = 1;
if (isset($_POST['submitted'])) {
$con = mysql_connect(" localhost","roo t","123456") ;
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db ("my_db", $con);
$sql="select * from quest where count = ".$_SESSION['count']."";
echo $sql;
$r=mysql_query( $sql);
if (!r)
{
die('Error: ' . mysql_error());
exit();
}
while($row = mysql_fetch_arr ay($r))
//while($_SESSION['count'] <<3)
{?>
<p style="color: #0000ff"><?php echo
$row['que'];?><table border='0'><tr> <td valign='top'><i nput
type='radio' name='quiz' value='4' /></td><td><?php echo
$row['op1'];?><br></td></tr><tr><td valign='top'><i nput
type='radio' name='quiz' value='3' /></td><td><?php echo
$row['op2'];?><br></td></tr><tr><td valign='top'><i nput
type='radio' name='quiz' value='2' /></td><td><?php echo
$row['op3'];?><br></td></tr><tr><td valign='top'><i nput
type='radio' name='quiz' value='1' /></td><td><?php echo
$row['op4'];?><br></td></tr></table><br></p></form>
<?php
$que=$_POST['que'];
$quiz=$_POST['quiz'];
$sql2="select answer from answerquest where que like ".$que." and
correctoption like ".$quiz."";
$run=mysql_quer y($sql2);
if(mysql_num_ro ws($run) == ""){
echo "wrong answer";
}else{
echo "right answer";
}
}
mysql_close($co n);
echo 'This is question no. '.$_SESSION['count'];
$_SESSION['count'] += 1;
}?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><ti tle>Questionnai re</title></head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="hidden" name="que" value="<?php=$r ow['que']?>">
<input type="submit" VALUE="Click here for the next question <?php
echo $_SESSION['count']; ?>" />
<input type="hidden" name="submitted " value="1" />
</form></body></html>
[/PHP]
sanjay
Comment