I have a select element that has dynamic options pulled on load from the MySQL database. Here's the code:
Code: Select all
<select name="missed_treatClin" class="validate-selection" id="missed_treatClin">
<option value=" " selected="selected">Please Select</option>
<?php
while($treatClin=mysql_fetch_array($result_user)){
$thername = $treatClin[user_fname]." ".$treatClin[user_lname];
echo "<option value=\"$thername\">$thername</option>";
}
?>
</select>Code: Select all
<select name="missed_aptTimeAMPM" id="missed_aptTimeAMPM">
<option value=" " selected="selected"> </option>
<option value="AM"<?php if (!(strcmp("AM", $row_missed['missed_aptTimeAMPM']))) {echo "selected=\"selected\"";} ?>>AM</option>
<option value="PM"<?php if (!(strcmp("PM", $row_missed['missed_aptTimeAMPM']))) {echo "selected=\"selected\"";} ?>>PM</option>
</select>/>So my questions is: When I set the select element in the page to dynamic, I seemed to have limited my ability to echo the php value if a particular option is selected, so when they go BACK to the form to update it, they have to select an option every time. I don't know how to echo the selected option inside the already generating PHP. Any suggestions?