I have a code that needs to get the value selected by the user and my code always picks the last code from the select.
<?php
$tipo_info = 0;
echo "<fieldset>Selecione, qual o tipo da informação que deseja cadastrar.<br />";
$query = $con->query("SELECT * FROM pv_tipo_info_questionario");
echo "<select>";
echo "<option></option>";
while($reg = $query->fetch_array()) {
echo "<option name='ativo' value='".$reg["cod_tipo_info"]."'>".$reg["tipo_info_questionario"]."</option>";
$tipo_info = $reg["cod_tipo_info"];
}
echo "</select>";
echo "<br /><br />";
switch ($tipo_info){
case 1:
echo "<button type=\"button\" disabled=\"true\" class=\"avancar btn btn-primary pull-right\">Avancar</button>";
break;
case 2:
echo "<button type=\"button\" disabled=\"true\" class=\"avancar btn btn-primary pull-right\">Avancar</button>";
break;
case 3:
echo "<button type=\"button\" disabled=\"true\" class=\"avancar btn btn-primary pull-right\">Avancar</button>";
break;
case 4:
echo "<button type=\"submit\" disabled=\"true\" class=\"avancar btn btn-primary pull-right\">Avancar</button>";
break;
}
?>