Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/74.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在select multiple中区分多个项目_Php_Html_Forms - Fatal编程技术网

使用PHP在select multiple中区分多个项目

使用PHP在select multiple中区分多个项目,php,html,forms,Php,Html,Forms,我在我的网站上有一个表格,可以为一篇文章选择多个其他编辑。 合格的编辑器列表得到了PHP的响应,它可以正常工作。但当选择了多个时,HTML会将其放入一个ID列表中。F.E.如果选择了Jay(id=4)和Sam(id=9)。收到的值将为$_POST['editors']=49 我的代码: <select multiple class="editors" name="editors" id="editors"> <?php //Gebruikers ophale

我在我的网站上有一个表格,可以为一篇文章选择多个其他编辑。 合格的编辑器列表得到了PHP的响应,它可以正常工作。但当选择了多个时,HTML会将其放入一个ID列表中。F.E.如果选择了Jay(id=4)和Sam(id=9)。收到的值将为$_POST['editors']=49

我的代码:

<select multiple class="editors" name="editors" id="editors">
    <?php
      //Gebruikers ophalen
      $editorArr = getEditors();
      foreach($editorArr as $editor){
        echo "<option value='".$editor['id']."'>".$editor['email'].' - '.$editor['type']."</option>";
      }
    ?>
 </select>
好的!试试这个:

<select class="editors" name="editors[]" id="editors" multiple>
<?php
    //Gebruikers ophalen
    $editorArr = getEditors();
    foreach ($editorArr as $editor) {
        echo "<option value='".$editor['id']."'>".$editor['email'].' - '.$editor['type']."</option>";
    }
 ?>
 </select>

名称应为数组,以便可以单独处理所有选定值

希望它有助于

可能重复的
<select class="editors" name="editors[]" id="editors" multiple>
<?php
    //Gebruikers ophalen
    $editorArr = getEditors();
    foreach ($editorArr as $editor) {
        echo "<option value='".$editor['id']."'>".$editor['email'].' - '.$editor['type']."</option>";
    }
 ?>
 </select>