Dear friends
Following peace of code for whenever we click for the next botton
then next question will come to database but its not working . some problem in this code so tell me where its wrong ?
[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']";$r=mysql_quer y($sql);
if (!r)
{
die('Error: ' . mysql_error());
exit();
}
while($row = mysql_fetch_arr ay($r))
{*?>**<h3><p* style="color: #0000ff"*>**<?p hp* echo
$row['que'];*?>**<table* border='0'*><tr ><td* valign='top'*>< input*
type='radio' name='quiz' value='4' */></td><td>**<?php* echo
$row['op1'];*?><br></td></tr>**<tr><td* valign='top'*>< input*
type='radio' name='quiz' value='3' */></td><td>**<?php* echo
$row['op2'];*?><br></td></tr>**<tr><td* valign='top'*>< input*
type='radio' name='quiz' value='2' */></td><td>**<?php* echo
$row['op3'];*?><br></td></tr>**<tr><td* valign='top'*>< input*
type='radio' name='quiz' value='1' */></td><td>**<?php* echo
$row['op4'];*?>**<br></td></tr>**</table>**<br></p></h3>*
*<?php*
}mysql_close($c on)
echo 'This is question no. '.$_SESSION['count'];
$_SESSION['count'] += 1;
}*?>*
*<!DOCTYPE *HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"*>*
*<html><head><t itle>*Questionn aire*</title></head>*
*<body>*
*<form* name="myform" method="POST" action="*<?php* echo
$_SERVER['PHP_SELF']; *?>*"*>*
*<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
Following peace of code for whenever we click for the next botton
then next question will come to database but its not working . some problem in this code so tell me where its wrong ?
[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']";$r=mysql_quer y($sql);
if (!r)
{
die('Error: ' . mysql_error());
exit();
}
while($row = mysql_fetch_arr ay($r))
{*?>**<h3><p* style="color: #0000ff"*>**<?p hp* echo
$row['que'];*?>**<table* border='0'*><tr ><td* valign='top'*>< input*
type='radio' name='quiz' value='4' */></td><td>**<?php* echo
$row['op1'];*?><br></td></tr>**<tr><td* valign='top'*>< input*
type='radio' name='quiz' value='3' */></td><td>**<?php* echo
$row['op2'];*?><br></td></tr>**<tr><td* valign='top'*>< input*
type='radio' name='quiz' value='2' */></td><td>**<?php* echo
$row['op3'];*?><br></td></tr>**<tr><td* valign='top'*>< input*
type='radio' name='quiz' value='1' */></td><td>**<?php* echo
$row['op4'];*?>**<br></td></tr>**</table>**<br></p></h3>*
*<?php*
}mysql_close($c on)
echo 'This is question no. '.$_SESSION['count'];
$_SESSION['count'] += 1;
}*?>*
*<!DOCTYPE *HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"*>*
*<html><head><t itle>*Questionn aire*</title></head>*
*<body>*
*<form* name="myform" method="POST" action="*<?php* echo
$_SERVER['PHP_SELF']; *?>*"*>*
*<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