PHP形式多个单选按钮 [英] php form multiple radio buttons
本文介绍了PHP形式多个单选按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图找到一种通用的方式来调出哪个单选按钮已被选中。
问题是,在我的foreach循环中使用$ _GET时,同时提交按钮也是循环中的回显。
I'm trying to find a generic way to call out which radio button has selected. Problem is, while using $_GET in my foreach loop, also submit button is echo in the loop.
任何人都可以告诉我如何避免这种情况,所以我只是显示单选按钮?
我不知道一种方法,因为foreach只是接受数组,据我所知
Can anyone tell me how to avoid this, so that I just show up the radio buttons? I do not know a way, because foreach just accepts arrays as far as I know
这里是我的代码
<form action="" method="get">
<input type="radio" name="one" value="One1" />One1<br/>
<input type="radio" name="one" value="One2" />One2 <br/>
<input type="radio" name="one" value="One3" />One3<br/>
<input type="submit" name="submit"/> <br/>
</form>
if(isset($_GET['submit'])){
foreach( $_GET as $key=>$val){
echo "$val <br/>";
}
}
推荐答案
just如果你的循环中的条件不会在你的表单中显示提交按钮,请尝试添加。
just try to add if condition in your loop will not show submit button in your form.
if(isset($_GET['submit'])){
foreach( $_GET as $key=>$val){
if($key != 'submit')
echo "$val <br/>";
}
}
希望它能帮助你
这篇关于PHP形式多个单选按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文