What is the best solution to make <select>
leave this selected result in a <select>
with many options?
I use IF in this situation with few options, but it is not feasible for a very large ...
Following sample code:
<select class="alterarperfilNomeInput2" name="sexo">
<?php
if ($row[sexo] == "Masculino")
{
echo "<option value=\"Masculino\" selected>Masculino</option>
<option value=\"Feminino\">Feminino</option>";
}
else
{
echo "<option value=\"Masculino\">Masculino</option>
<option value=\"Feminino\" selected>Feminino</option>";
}
?>
</select>
It also follows select code that I need to leave a selected option just according to BD ...
<select name="dia" class="alterarperfilNomeInput2A">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>