Hello
I have a maybe simple problem, but I can not think of any way to solve it.
I have a database where I have a table of products on it. In this table, you have the cor
column. So I'm creating a filter when searching the products on the site and as I'm not sure exactly what colors are in stock, I made this while to print the options:
$sql = "SELECT 'cor' FROM 'produtos'";
<select id='iCor' name='nCor'>
<option value=''>Todos</option>";
while($linha = $result->fetch_assoc()){
$cor = $linha['cor'];
echo"<option value='$cor'>$cor</option>";
}'
But this with this form if I have registered the following colors: amarelo
, verde
, vermelho
, amarelo
, will appear 2 options
containing option amarelo
.
What I want is that somehow, be checked if you already have that option
no select
. If you have, you do nothing. If you do not, put the color as new option