Hi!
I'm trying to solve a php search problem here. Maybe someone could help...
I have a MySQL table with three colums: Headline, introduction and article.
If someone enters three words into the search form and starts a search of these, then
A) all these words are being searched from each of these columns as one phrase. This is simple code. (select * from table where headline LIKE $search OR...) But...
😎 ...if there are no search results found, the phrase is divided into 3 different words and each word is searched from the columns separately.
Meaning:
we have to find all the rows in the table, that contain the FRIST word (weather in the headline, introduction or article column). If there are some search results, then...
...the second word is beeing searched ONLY from these rows, that we wound previously. Again, the search is done in all the three columns. if there are search results, then finally...
...the third word is searched ONLY from these rows, that contain the first and the second word.
And finally I get the ID of the row, that matches all these 3 points criterias.
Hope you got the idea? In my example, I took 3 words. But the script has to work in case of X words.
So I belive, that 'explode' has to be done first to the $search and the B script should start something like this:
$words = explode(" ", $search);
for ($i=0;$i<count($words);$zx++)
{
$s = "%".$words[$i]."%";
...but what comes here?
}
if anything remained unclear, let me know...
thnx!