我有一个带分组单选按钮的html表单。这种形式包含有任何疑问或任何选项用PHP计算html单选按钮值
<form action="results.php" method="post" enctype="multipart/form-data"><br>
<p>Have you ever turned a client down?</p>
<div id="q_1">
<input type="radio" name="q[]" id="q_1_yes" value="yes">
<label for="q_1_yes">Yes</label>
<input type="radio" name="q[]" id="q_1_no" value="no">
<label for="q_1_no">No</label>
</div><br>
<p>Are you comfortable with failure?</p>
<div id="q_1">
<input type="radio" name="q[]" id="q_2_yes" value="yes">
<label for="q_2_yes">Yes</label>
<input type="radio" name="q[]" id="q_2_no" value="no">
<label for="q_2_no">No</label>
</div><br>
<p>Can your concept be easily described and understood?</p>
<div id="q_1">
<input type="radio" name="q[]" id="q_3_yes" value="yes">
<label for="q_3_yes">Yes</label>
<input type="radio" name="q[]" id="q_3_no" value="no">
<label for="q_3_no">No</label>
</div><br>
<input type="submit" name="sub_eit" id="sub_eit" value="Submit">
</div>
</form>
我知道我可以指望的单选按钮的数量与名称q
$count_cbox = count($_POST['q'])
但有可能的是,当用户进行选择,我算单选按钮值=“是”或“否”。
遍历'$ _POST'并计算发现'yes'的频率,然后使用'switch(yesCount){case 1:/ *任何代码*/break;情况2:/ *任何代码*/break;}' –
您可以使用某些count变量或将结果存储在数组中。 –
顺便说一句'推荐'而不是'推荐' –