在php中标识$\u POST类型

在php中标识$\u POST类型,php,post,foreach,Php,Post,Foreach,嗨,我在表格中有很多输入,其中一些是单选按钮,另一些是文本和文本框。我得到了所有这些值 foreach ($_POST as $name => $val) { //for example if post type==radio //there is some insertion codes to db in here $name,$val... } 但如果post值是单选按钮,我希望使用该插入。我怎么做 我的表格看起来像 <form method="post" action=

嗨,我在表格中有很多输入,其中一些是单选按钮,另一些是文本和文本框。我得到了所有这些值

foreach ($_POST as $name => $val)
{
 //for example if post type==radio
 //there is some insertion codes to db in here $name,$val...

}
但如果post值是单选按钮,我希望使用该插入。我怎么做

我的表格看起来像

<form method="post" action="<?=$_SERVER['REQUEST_URI']?>">
.
.
.
//a lot of table,tr,td,input,etc. in this part
.
.
.

<td style="border-style:solid; border-width:2px 1px 1px 2px"><input type="radio" class="metalYayaKorkuluk_Deformasyon" name="metalYayaKorkuluk_Deformasyon" style="width:100%; margin:0px; display:table-caption" value="1" /></td>
<td style="border-style:solid; border-width:2px 1px 1px 1px"><input type="radio" class="metalYayaKorkuluk_Deformasyon" name="metalYayaKorkuluk_Deformasyon" style="width:100%; margin:0px; display:table-caption" value="2" /></td>
<td style="border-style:solid; border-width:2px 1px 1px 1px"><input type="radio" class="metalYayaKorkuluk_Deformasyon" name="metalYayaKorkuluk_Deformasyon" style="width:100%; margin:0px; display:table-caption" value="3" /></td>
<td style="border-style:solid; border-width:2px 2px 1px 1px"><input type="radio" class="metalYayaKorkuluk_Deformasyon" name="metalYayaKorkuluk_Deformasyon" style="width:100%; margin:0px; display:table-caption" value="4" /></td> 

<td style="border-style:solid; border-width:1px 1px 2px 2px"><input type="radio" class="plastikKaplama4" name="plastikKaplama4" style="width:100%; margin:0px; display:table-caption" value="1" <?php echo ($plastikKaplama4=='1')?'checked':'' ?>/></td>
<td style="border-style:solid; border-width:1px 1px 2px 1px"><input type="radio" class="plastikKaplama4" name="plastikKaplama4" style="width:100%; margin:0px; display:table-caption" value="2" <?php echo ($plastikKaplama4=='2')?'checked':'' ?>/></td>
<td style="border-style:solid; border-width:1px 1px 2px 1px"><input type="radio" class="plastikKaplama4" name="plastikKaplama4" style="width:100%; margin:0px; display:table-caption" value="3" <?php echo ($plastikKaplama4=='3')?'checked':'' ?>/></td>
<td style="border-style:solid; border-width:1px 2px 2px 1px"><input type="radio" class="plastikKaplama4" name="plastikKaplama4" style="width:100%; margin:0px; display:table-caption" value="4" <?php echo ($plastikKaplama4=='4')?'checked':'' ?>/></td>


<input id='elm2' type="submit" name="save2" value="Submit" />

</form>

您应该使用Javascript为每个输入发布隐藏的输入

<input type="hidden" name="radio" value="input1,input2" />

这里有一些语法错误。请参考以下链接,并将其应用于您的代码。$\u POST数组不包含有关值来自哪个输入类型的任何信息。您需要根据名称进行筛选。或者将您的选择输入类型命名为独特的名称,例如name=“select\u foo”,即使您进行了编辑,它仍然包含语法错误。使用我提供给您的链接对代码进行故障排除/调试。我们也不知道你的$\u帖子是什么样子的。我正试图在我的代码中应用这一点。好的,那么你用的表单在哪里?
expload
你在这里走得太快了。主要打字错误。
$radios = explode(',',$_POST['radio']);
foreach($radios as $value) {
    $radio_value = $_POST[$value];
    // Do you want
}