1
我有一個包含選擇表單字段的表單。字段選項由MySQL查詢和PHP回波動態生成: -從數組和MySQL查詢生成動態表單選擇字段
<select name="students" size="10" multiple="multiple">
<?php
do {
?>
<option value="<?php echo $row_rsStudents['student_id']?>"><?php echo $row_rsStudents['student_sname1']?> <?php echo $row_rsStudents['student_sname2']?> <?php echo $row_rsStudents['student_fname']?>: "</option>
<?php
} while ($row_rsStudents = mysql_fetch_assoc($rsStudents));
$rows = mysql_num_rows($rsStudents);
if($rows > 0) {
mysql_data_seek($rsStudents, 0);
$row_rsStudents = mysql_fetch_assoc($rsStudents);
}
?>
</select>
我也有我所分解和循環的數組: -
<?php
$studentsids = $row_rsClasses['class_students'];
$students = explode(":", $studentsids);
for($i = 0; $i < count($students); $i++){
echo "$students[$i]";
}
?>
但我想的匹配條目,以顯示在選擇字段中選擇。任何幫助感激地讚賞。