help with yes/no radio button for multiple questions pull from database
- by Darlene
hey guys i need a little help with this questionaire form.
The tables currently using are:
user
userid| username
answers
aswerid|quesid|ans|userid|date
ques
quesid|ques
The form below is what im using however i'm gettin errors for radio button.... could anyone offer advice?
$query = mysql_query("SELECT * FROM ques", $con)
or die("Cannot Access tblprequeations From Server");
echo"<div id='quesform' class='quesform'>";
echo"<form name='QForm' method='post' action='answers.php' onsubmit='return validateQForm(this);'>";
echo"<p>";
while($row = mysql_fetch_array($query))
{
echo"<p>";
echo"<label>".$row['quesid']."</label> ";
echo"<label>".$row['ques']."</label> ";
echo"<input type='radio' name='ans' value='yes' if (isset($_POST['ans']) && $_POST['ans'] == 'yes') echo'checked'/>";
echo"<input type='radio' name='ans' value='no' if (isset($_POST['ans']) && $_POST['ans'] == 'no') echo'checked'/>";
echo"</p>";
}
echo"</p>";