I have a select
with five option
. I want it to check the link that the user is and according to that link, he selects an option.
My HTML:
<select name="segmento" id="segmento" class="basic">
<option value="">Segmento</option>
<option value="Teste Engenharia">Teste Engenharia</option>
<option value="Teste Hospitalar">Teste Hospitalar</option>
<option value="Teste Iluminação">Teste Iluminação</option>
<option value="Teste Elevadores">Teste Elevadores</option>
</select>
I'm trying to do via PHP with preg_match
, but my knowledge is limited, so I'm probably doing something wrong.
What I'm trying to do:
<option
<?php
if (preg_match( '/segmentos\/teste-hospitalar/',$database->parametros['menuRoteador']))
echo 'value="teste Hospitalar" Teste Hospitalar';
elseif (preg_match('/segmentos\/neomot-elevadores/',$database->parametros['menuRoteador']))
echo 'value="Teste Elevadores" Teste Elevadores';
elseif (preg_match('/segmentos\/neomot-engenharia/',$database->parametros['menuRoteador']))
echo 'value="Teste Engenharia" Teste Engenharia';
?>
>
</option>
It should be occupied by the value of <option value="">Segmento</option>
, but this is not happening.