我在 PHP 中创建了一个下拉列表,它选择了列表的最后一项,我不知道为什么会这样。
当我回显 event_id (返回的值)时,它每次都是最后一项。该列表已正确填充。
$forms = mysql_query("select events.event_title, events.event_id, saved_forms.id from events
INNER JOIN saved_forms on saved_forms.id = events.event_id
where saved_forms.form_type = 'e' and events.event_by = '$my_username'");
while($form = mysql_fetch_array($forms)){
$form_id = $form['event_id'];
$selection.="<OPTION VALUE=\"$form_id\">".$form['event_title']."</OPTION>";
}
?>
<div id="saved_forms">
<tr><td><select name ="saved_form" value ="<? echo $form_id; ?>" onchange="showUser(<? echo $form_id; ?>)">
<Option value="$form_id"><? echo $selection; ?></Select></td><td>Select Existing Form</td></tr>
</div>