I'm trying to retrieve a value from my database and put it as a selected value in my <select>
element, but the problem is that it is not showing the value retrieved in the <select>
menu.
The variable $level contains the value "6ème", so the problem is not from an empty variable but from the select menu and the selected option I guess. Here is my code :
<select name="level" class="form-control selectpicker" value="05">
<?php if($level="") {?>
<option value=" " > Please choose your level </option>
<?php }
else {?>
<option selected="selected" value=" " > <?php echo $level; ?> </option> <?php } ?>
<option value="01">1st</option>
<option value="02">2nd</option>
</select>
When I'm putting text instead of $level, it's showing it.