目前使用的表格是:
user
userid| username
answers
aswerid|quesid|ans|userid|date
ques
quesid|ques
下面的表格是我正在使用但是我对单选按钮的错误....有人可以提供建议吗?
$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>";
答案 0 :(得分:0)
echo"<input type='radio' name='ans' value='no' if (isset($_POST['ans']) && $_POST['ans'] == 'no') echo'checked'/>";
您没有关闭第一个"
的{{1}},它应该在echo
之前关闭
PS:偏离主题,投票结束。
答案 1 :(得分:0)
echo "<input type='radio' name='ans' value='no' ".((isset($_POST['ans']) && $_POST['ans'] == 'no')?'checked':'')."/>";