Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用复选框发送多个值_Php_Checkbox - Fatal编程技术网

Php 使用复选框发送多个值

Php 使用复选框发送多个值,php,checkbox,Php,Checkbox,我有一张表格,该表格包含以下表格: <?php foreach($resultTable as $key => $value) { ?> <table> <tr> <td><input type = "checkbox" name="idPriv[]" id="idPriv" onclick="evaluateIT(this)" data-related

我有一张表格,该表格包含以下表格:

<?php foreach($resultTable as $key => $value)
    {
    ?>
        <table>
           <tr>
              <td><input type = "checkbox" name="idPriv[]" id="idPriv"  onclick="evaluateIT(this)" data-related-item="adminPanelShow" value ="<?php echo $value["id"]?>" />
                  <input name="rowID[]" id="rowID[]" class="adminPanel" hidden="hidden" type="text" value="<?php echo $value["id"]?>"/></td>
              <td><input type="text" name="userName[]" id="userName" class="adminPanel" value="<?php echo $value["userName"]?>"/></td>
              <td><input  name="firstName[]" type="text" id="firstName" class="adminPanel" value="<?php echo $value["firstName"]?>"/></td>
           </tr>
<?php } ?>

        </table>


要检查复选框是否选中,请按如下方式对其进行分析:

foreach($resultTable as $key => $value)
{
    if($value==="on")
    {
        // checked checkbox has a value of "on"
        // triple = sign means value is exactly "on"
    }
}

用复选框值连接每个
用户名
名字
字段:

foreach($resultTable as $key => $value)
{?>
    <table>
       <tr>
          <td><input type = "checkbox" name="idPriv[]" id="idPriv"  onclick="evaluateIT(this)" data-related-item="adminPanelShow" value ="<?php echo $value["id"]?>" />
              <input name="rowID[]" id="rowID[]" class="adminPanel" hidden="hidden" type="text" value="<?php echo $value["id"]?>"/></td>
          <td><input type="text" name="userName[<?php echo $value["id"]?>]" id="userName" class="adminPanel" value="<?php echo $value["userName"]?>"/></td>
                                                 ^--- here
          <td><input  name="firstName[<?php echo $value["id"]?>]" type="text" id="firstName" class="adminPanel" value="<?php echo $value["firstName"]?>"/></td>
                                       ^--- here
       </tr>
}
</table>

name=“userName[]”
您的标记失败。修好它。(您正在打开但没有关闭表,为什么您一直在打开新表?。
foreach ($_POST[`idPriv`] as $id) {
    $firstName = $_POST['firstName'][$id];
    $userName = $_POST['userName'][$id];
    // ...
}