我試圖從$staff
得到一個選擇列表我正在掙扎的是選擇已經從$entry->enrolments
註冊的工作人員。php陣列爲每個在每個
如果存在於$entry->enrolments
的$staff id
在選擇列表中
$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>
任何幫助/指導值將不勝感激。 在此先感謝
究竟是什麼問題? – jeroen
嘗試在第一次foreach後產生更多輸出 – Gntem