I have allowed myself to reproduce your code on a hypothetical value, if you were obtaining data from the BD and reading them properly, there would actually be a select
with options.
But said select
would not be in accordance with the syntax, according to which the value
must be enclosed in quotes. That, although in my case both select
are displayed, can be cause of errors in some browsers, or when recovering the value
in another site.
Code Play
<?php
$resultado =
array("1"=>"Municipio1", "2"=>"Municipio2", "3"=>"Municipio3");
$html_bien="VALUE CON COMILLA Y SIN NADA DESPUÉS DE <\option> \n";
$html_mal="LOS VALUE NO TIENEN COMILLAS\n";
if ($resultado)
{
$html_mal.="<select>";
$html_bien.="<select>";
foreach ($resultado as $k => $valor)
{
$html_bien.='<option value="'.$valor.'">'.$valor.'</option>';
$html_mal.="<option value=".$valor.">".$valor."</option>\n";
}
$html_mal.="</select>";
$html_bien.="</select>";
echo $html_bien."\n\n";
echo $html_mal;
}
?>
Result
VALUE CON COMILLA Y SIN NADA DESPUÉS DE <\option>
<select>
<option value="Municipio1">Municipio1</option>
<option value="Municipio2">Municipio2</option>
<option value="Municipio3">Municipio3</option>
</select>
LOS VALUE NO TIENEN COMILLAS
<select>
<option value=Municipio1>Municipio1</option>
<option value=Municipio2>Municipio2</option>
<option value=Municipio3>Municipio3</option>
</select>