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