You would just do an if statement, say $mustapprove has either yes or no in it:
print("yes<input type=\"radio\" name=\"editapproval\" value=\"yes\"");
if ($mustapprove == "yes") {
print(" checked=\"checked\"");
}
print(" />\n");
print("no<input type=\"radio\" name=\"editapproval\" value=\"no\"");
if ($mustapprove == "no") {
print(" checked=\"checked\"");
}
print(" />\n");
or, you could do:
switch ($mustapprove) {
case "yes":
print("yes<input type=\"radio\" name=\"editapproval\" value=\"yes\" checked=\"checked\" />\n");
print("no<input type=\"radio\" name=\"editapproval\" value=\"no\" />\n");
break;
case "no":
print("yes<input type=\"radio\" name=\"editapproval\" value=\"yes\" />\n");
print("no<input type=\"radio\" name=\"editapproval\" value=\"no\" checked=\"checked\" />\n");
break;
}
or anything of that sort.
Brandon
edit: sorry! I didn't see someone already answered just now
Originally posted by Radon3k
How do I get a form to show the value from a field in the database on a radio form? This is what I have but it doesn't work:
$getperms = "SELECT * FROM editorialperms";
$getpermsquery = mysql_query($getperms) or die(mysql_error());
$permsrow = mysql_fetch_array($getpermsquery);
$mustapprove = $permsrow['mustapprove'];
?>
<form method="post" action="<?$PHP_SELF?>">
<?php
echo("
<table border='0' cellspacing='0' cellpadding='0' width='100%'>
<tr>
<td>Editorials must be approved?</td>
<td>Yes<input type='radio' name='editapproval' value='$mustapprove'>
No<input type='radio' name='editapproval' value='$mustapprove'></td>
</tr>
<tr>
<td></td>
<td><input type='submit' name='submitapproval' value='Validate'></td>
</tr>
</table>
</form>
");
Thanks. 🙂 [/B]