我正在尝试从 中获取值的选择列表$staff
我正在努力选择已经注册的员工$entry->enrolments
。
如果$staff id
存在于$entry->enrolments
选择列表中选择它
$entry
= 从 mysql 记录
$staff
= 数组中的人员列表。
$entry->enrolments
= 注册员工的逗号分隔值
<select name="tutor[]" id="tutor" multiple="multiple" size="5" class="required" title="Select Staff">
<?php
$entry = get_record("staff_development", "id", $id);
$staff = get_records("user", "deleted", "0", "lastname ASC", "id,firstname,lastname,idnumber");
$sdenrolments=array($entry->enrolments);
$people = explode(",", $entry->enrolments);
foreach($staff as $tutor){
foreach($people as $person){
if($tutor->id>1)echo '<option value="'.$tutor->id.'"';
if ($person==$tutor->id) {echo 'selected="selected"';}
echo '>'.$tutor->lastname.' '.$tutor->firstname.'</option>';
}
}
?>
</select>
任何帮助/指导将不胜感激。提前致谢