duandu1915 2012-11-04 22:46 采纳率: 100%
浏览 43

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

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>";
  • 写回答

2条回答 默认 最新

  • douqipi9704 2012-11-04 22:53
    关注
    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.

    评论

报告相同问题?