帮助是/否单选按钮从数据库中提取多个问题

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>&nbsp; &nbsp;";
            echo"<label>".$row['ques']."</label>&nbsp; &nbsp;";
    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>";
echo"<input type='radio' name='ans' value='no' if (isset($_POST['ans']) && $_POST['ans'] == 'no') echo'checked'/>";

You are not closing the " from the first echo, it should close before the if

PS: Off topic, voting to close.

echo "<input type='radio' name='ans' value='no' ".((isset($_POST['ans']) && $_POST['ans'] == 'no')?'checked':'')."/>";
  1. do not use if statement inside echo.
  2. do not echo inside echo.
  3. always use concatenation if you have somethin to add conditionally inside the string.
  4. ((isset($_POST['ans']) && $_POST['ans'] == 'no')?'checked':'') -> this another way of if else statemnt