您好,我有这个带有数据库名称列表的 html 表单。
$stmt = $db->query("SELECT id_person, surname, firstname FROM persons ORDER BY surname,firstname");
$selected_persons= array();
echo "<select name='persons[]' multiple='multiple' size='7'>";
while ($result = $stmt->fetch()) {
echo "<option value='".$result['id_person']."'";
if (in_array($result['id_person'], $selected_persons)) {
echo " selected='selected'";
}
echo ">".$result['surname']." ".$result['firstname']."</option>";
我需要foreach循环来返回id_person
选定的人