How do I display the state of a radio button?

B

Bob Sanderson

I am using a PHP/HTML form to access a MySql database. Some of the entries
use radio buttons.

<td><input name="Flag1" type="radio" value="1" /></td>
<td><input name="Flag1" type="radio" value="2" /></td>
<td><input name="Flag1" type="radio" value="3" /></td>
<td><input name="Flag1" type="radio" value="4" /></td>

This part works fine. I have created a form to permit the operator to edit
a record. This form is identical to the input form and displays the data
for the record selected. What I can't figure out how to do is to display
the data in the radio button fields. The PHP script correctly returns the
data but I don't know how to check the correct button. It seems like this
would be a pretty common thing, but I haven't been able to find it.

Any help will be greatly appreciated.
 
B

BootNic

Bob Sanderson said:
[email protected]
I am using a PHP/HTML form to access a MySql database. Some of the
entries use radio buttons.

<td><input name="Flag1" type="radio" value="1" /></td>
<td><input name="Flag1" type="radio" value="2" /></td>
<td><input name="Flag1" type="radio" value="3" /></td>
<td><input name="Flag1" type="radio" value="4" /></td>

This part works fine. I have created a form to permit the operator to
edit a record. This form is identical to the input form and displays
the data for the record selected. What I can't figure out how to do
is to display the data in the radio button fields. The PHP script
correctly returns the data but I don't know how to check the correct
button. It seems like this would be a pretty common thing, but I
haven't been able to find it.

Any help will be greatly appreciated.

<?php
$string = $_SERVER["HTTP_ACCEPT"];
$myxml=stristr($string, 'application/xhtml+xml');
if($myxml === FALSE) {
header("Content-Type:text/html; charset=utf-8");
}
else{ header("Content-Type:application/xhtml+xml;charset=utf-8");
print "<?xml version='1.0' encoding='utf-8'?>
";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content=
"text/html; charset=utf-8" />
<title></title>
</head>
<body>
<? if($_POST){print "<p>Flag1 " .$_POST['Flag1']. " data checked</p>";} ?>
<form action="" method="post">
<table summary="">
<tbody>
<tr>
<td><input name="Flag1" type="radio" value="1"
<? if($_POST['Flag1']=='1'){print ' checked="checked" ';} ?>/></td>
<td><input name="Flag1" type="radio" value="2"
<? if($_POST['Flag1']=='2'){print ' checked="checked" ';} ?>/></td>
<td><input name="Flag1" type="radio" value="3"
<? if($_POST['Flag1']=='3'){print ' checked="checked" ';} ?>/></td>
<td><input name="Flag1" type="radio" value="4"
<? if($_POST['Flag1']=='4'){print ' checked="checked" ';} ?>/></td>
</tr>
<tr>
<td colspan="4"><input type="submit" value="test" /></td>
</tr>
</tbody>
</table>
</form>
</body>
</html>

--
BootNic Thursday, November 02, 2006 12:15 PM

"The POP3 server service depends on the SMTP server service, which
failed to start because of the following error: The operation
completed successfully."
*Windows NT Server v3.51*
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top