I have this form with about 9 drop down menus. I am trying to retain the selected values after submission. My code works for 2 of those drop down menus which are not disabled, but not for the remaining 7 disabled ones. Is there a different way to write the code for those?
1 of the 2 drop downs that isn't disabled:-
<?php
$sql = "SELECT * FROM tablename1 ";
$result = mysqli_query($conn, $sql);
echo "<select name = 'account_name' id = 'idaname'>";
echo "<option value = ''>";
while($row = mysqli_fetch_array($result)){
$selected = (isset($_POST['account_name']) && $_POST['account_name'] == $row['account_name']) ? 'selected = "selected"' :'';
?>
<option <?php echo $selected; ?> value = "<?php echo $row['account_name']; ?>"> <?php echo $row['account_name']; ?> </option>
<?php } ?>
</select>
2 of the 7 disabled drop downs :-
<?php
$sql = "SELECT rsm_val FROM tablename2 ";
$result = mysqli_query($conn, $sql);
echo "<select name = 'rsm_val' id = 'rsm_val' onchange = 'runrsm()' disabled >";
echo "<option value = '" .$rsm_val . "'>" . $rsm_val . "</option>";
while($row = mysqli_fetch_array($result)){
$selected = (isset($_POST['rsm_val']) && $_POST['rsm_val'] == $row['rsm_val']) ? 'selected = "selected"' :'';
?>
<option <?php echo $selected; ?> value = "<?php echo $row['rsm_val']; ?>"> <?php echo $row['rsm_val']; ?> </option>
<?php } ?>
</select>
<select name = 'boost_app' id = 'boost_app' onchange = 'runboost()' disabled>
<?php echo "<option value = '". $boost_app . "'>" . $boost_app . "</option>"; ?>
<option <?php if($_POST['boost_app'] == 'Yes'){?> selected="true" <?php }; ?> value = "Yes">Yes</option>
<option <?php if($_POST['boost_app'] == 'No') {?> selected="true" <?php }; ?> value = "No">No</option>
</select>