0
Good staff I am with a doubt, I am trying to return from the comic only states that possess the searched term however I do not want to repeat them. follows the code
<?php
$search_term = filter_var($_GET["s"], FILTER_SANITIZE_STRING);
$q = "SELECT DISTINCT estado FROM classificados WHERE texto LIKE '%".$search_term."%' ";
$r = mysql_query($q);
if(mysql_num_rows($r)==0)// se nao encontrar resultado
{
echo "--";
}
else //se encontrar algum resultado
{ echo " <option value='index.php?s=$search_term&e=$estado'> $estado </option>" ;} ?>
</select>
Good afternoon. From what I see your query is correct. It is giving some error or similar?
– Edgar Muniz Berlinck
But I guess your problem isn’t with the distinct. He prints the '--'? From what I’m seeing, the error is in Else, I think you’d have to loop and print the results and not the way you’re doing it there. I just don’t answer because I’m not smart in PHP.
– Edgar Muniz Berlinck
Looks like we’re missing one
mysql_fetch_assoc()
before the echo of option.$estado
was defined where?– rray
at the beginning of the code after the connection
– Arsom Nolasco