Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
I have 4 radios buttons that you choose from for a test on one form and then at the bottom I have a Back button and a Next button, How Do I Make It So When You Click The Back Button It See What Radio Button that you were Checked and then click the Next button it still checked. And this my code.Code: Select all
<html>
<head>
<title>Exam Online</title>
</head>
<body>
<div align=center>
<form action="<?=$PHP_SELF?>?Prev_Page=$Prev_Page&Next_Page=$Next_Page" method="post">
<?
$conn = mysql_connect( $hostname, $username, $password );
mysql_query("SET NAMES TIS620");
if ( ! $conn )
die( "Can't connect to MySQL" );
mysql_select_db( $dbname, $conn )
or die ( "Can't Select the $dbname" );
$strSQL = "select * From lesson1 ";
/* Set variable for a page */
$Per_Page =1;
if(!$Page)
$Page=1;
switch ($_POST['Page'])
{
case 'Back' :
$Prev_Page = $Page-1;
break;
case 'Next' :
$Next_Page = $Page+1;
break;
}
$result = mysql_query($strSQL);
$Page_start = ($Per_Page*$Page)-$Per_Page;
$Num_Rows = mysql_num_rows($result);
if($Num_Rows<=$Per_Page)
$Num_Pages =1;
else if(($Num_Rows % $Per_Page)==0)
$Num_Pages =($Num_Rows/$Per_Page) ;
else
$Num_Pages =($Num_Rows/$Per_Page) +1;
$Num_Pages = (int)$Num_Pages;
if(($Page>$Num_Pages) || ($Page<0))
print "<center><b>จำนวน $Page มากกว่า $Num_Pages ยังไม่มีข้อความ<b></center>";
$strSQL .= " Where 1 Order by Number LIMIT $Page_start , $Per_Page";
$result = mysql_query($strSQL);
While($rs= mysql_fetch_array($result))
{
echo "<table cellpadding=\"4\" cellspacing=\"3\" border=\"1\" border width= \"65%\" align=\"center\" bgcolor=\"lavender\">
<tr>
<td>$rs[Number]."." $rs[Question]</td>
</tr>\n";
?>
<td><input type="radio" name="C$rs[0]" value="Choice1"> <?echo $rs[Choice1];?></td>
</tr>
<td><input type="radio" name="C$rs[0]" value="Choice2"> <?echo $rs[Choice2];?></td>
</tr>
<td><input type="radio" name="C$rs[0]" value="Choice3"> <?echo $rs[Choice3];?></td>
</tr>
<td><input type="radio" name="C$rs[0]" value="Choice4"> <?echo $rs[Choice4];?></td>
</tr>
<?
echo "<td align=\"center\"><img src=$rs[Pictures]></td>\n
</tr>\n
</table>";
}
echo "<table cellpadding=\"4\" cellspacing=\"3\" border=\"0\" border width= \"65%\" align=\"center\" bgcolor=\"lavender\">\n";
/* Back Button */
if($Prev_Page)
?>
<td align="left"><input type="submit" name="Page" value="Back"></td>
<? /* Next Button */
if($Page!=$Num_Pages)
?>
<td align="right"><input type="submit" name="Page" value="Next"></td>
<?
echo "</table>";
mysql_close( $conn );
?>
</div>
</form>
</body>
</html>hawleyjr | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]