Checking Radiobuttons
Posted: Sat Jun 05, 2004 10:08 pm
I have a noob question that I can't get past. I'm working on a little edit/update script and have run into a problem prechecking radiobuttons from data I queried from the database. Here is the part of the script where I am having trouble.
What I'm trying to do is if the value from the database = 1, then it will check yes. But, if the value = 0 or nothing, it will check no. I've tried the script above but it returns parse error on that line. If anyone could clear up this problem, I'd appreciate it.
Code: Select all
<?php
echo ("
Yes: <input type="radio" ". if ($row["a1"]=='1') {echo('checked');} ." name="a1" value="1"> No: <input type="radio" ". if ($row["a1"]=='1'||$row["a1"]=='') {echo('checked');} ." name="a1" value="0">
");
?>