以下是我用于动态显示下拉列表的代码。但是我发布后无法保留下拉列表的值?我能够插入值并能够保留textboxes的值。但是无法保留下拉列表
可用的医生
<?php
$selectedDoctor = $_POST["doctortype"];
$sql = "select firstname from users where userid in (select userid from doctortype where doctortype = \"$selectedDoctor\");";
include_once("inc_databaseClass.php");
$dClass=new databaseClass;
$results=$dClass->connect();
$result = mysqli_query($results,$sql);
echo "<select name = 'selectDoctors' id = 'idaname'>";
echo "<option value = ''>";
while ($row = mysqli_fetch_array($result)) {
$selected = (isset($_POST['selectDoctors']) && $_POST['selectDoctors'] == $row['firstname']) ? 'selected = "selected"' :'';
?>
<option <?php echo $selected; ?> value = "<?php echo $row['firstname']; ?>"> <?php echo $row['firstname']; ?> </option>
<?php } ?>
</select>
</p>