I created a drop down list in PHP and it's selecting the last item of the list and I can't figure out why it's doing this.
When I echo the event_id (the value that is returned), it's the last item every time. The list is populated correctly.
$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>
<select>, and not use themysql_*extensions as they have been deprecated - go withmysqliorPDOinstead.JSONif it's andAJAXrequest, notHTML.