2
my scenario and the following, I have an input where the user puts the term and clicks on search
EX: car horizon [ENTER]
however you are listing the result of the separate words
EX: 3 results found
id1 - house in beautiful horizon
id2 - accept car in exchange
id3- car located in beautiful horizon
I would like you to display only the result that contains the 2 words
EX: 1 result found
id1- car located in beautiful horizon
?>
$search_term = filter_var($_GET["s"], FILTER_SANITIZE_STRING);
$palavras = explode(" ", $search_term);
for ($i = 0; $i < count($palavras); $i++)
$q = "SELECT * FROM classificados WHERE texto LIKE '%".$palavras[$i]."%' AND aprovado='s' ORDER BY ID desc";
$r = mysql_query($q);
if(mysql_num_rows($r)==0)//no result found
{
echo "<div id='search-status'>Nenhum resultado encontrado!</div>";
}
else //result found
{
echo "<ul>";
while($row = mysql_fetch_assoc($r))
{
$title = $row['texto'];
?>
I hope I have well illustrated my doubt
If I understood the question correctly, you would have to put each word in a type like this: "SELECT * FROM table WHERE text LIKE '%". $palavras1." %' AND LIKE '%". $palavras2." %' AND aprovado=’s' ORDER BY ID desc"; that’s about it ?
– Diego Filipe Pedro Santos
Isn’t this what you want? If it is, the code is practically ready in the answer. http://answall.com/a/13181/70
– Bacco
diego segue $palavras = explode(" ", $search_term); for ($i = 0; $i < Count($words); $i++) $q = "SELECT * FROM classifieds where text = '%". $palavras[$i]." %' AND aprovado=’s' ORDER BY ID desc";
– Arsom Nolasco
In parts it is true @Bacco, but he may be wanting the treatment to split the two words of the input.
– Diego Filipe Pedro Santos
vi yes Diego however the search is only in a field ( text) in this result the very like ja made, and what I would like is to only list the results containing the keywords in the same text
– Arsom Nolasco
See if you can help http://forum.imasters.com.br/topic/509139-encontrara-palavra-como-elafoi-typed/
– Motta
Good Motta I thought this problem was simpler to solve, but I took a look at MATCH AGAINST and it can be that I will solve even though I will leave to study tomorrow this part because I am working now
– Arsom Nolasco