0
Hello!
I have a problem maybe simple, but I can’t think of any way to solve it.
I have a database where I have a product table in it. In this table, there is the column cor. So, I’m creating a filter to search the products on the site and since I don’t know exactly what colors are in stock, I did 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 one with this shape if I have registered the following colors: amarelo, verde, vermelho, amarelo, will appear 2 options containing the option amarelo.
What I want is that somehow, be checked if you already have that option in the select. If it has, it does nothing. If it does not, set the color to new option
I don’t know why you got a -1, it really worked!
– Nicolas S.