searching a database using multiple words
Moderator: General Moderators
searching a database using multiple words
helloe there
I am putting together a searcg engine on my web page to query the fields of a database.
Where the search is for a whole word or short title, it is okay. The problem i have is when i get the user to do a search for multiple words where each word is searched independantly.
Could somebody help me with this please.
I am putting together a searcg engine on my web page to query the fields of a database.
Where the search is for a whole word or short title, it is okay. The problem i have is when i get the user to do a search for multiple words where each word is searched independantly.
Could somebody help me with this please.
Code: Select all
SELECT * FROM table_name WHERE col1 LIKE "%$word1%" OR col1 LIKE "%$word2%"Thanks but that bit i understand that part.
BUT there could be 2 words or there could be 10 words. So how would i do that.
All the words are typed into one text box. How do i first retrieve the values and break the string into its individual word parts.
Then how/what do i do to take all that information and construct the querystring.
BUT there could be 2 words or there could be 10 words. So how would i do that.
All the words are typed into one text box. How do i first retrieve the values and break the string into its individual word parts.
Then how/what do i do to take all that information and construct the querystring.
Now this is the kind of thing that seperates the men from the boys so to speak. Do I figure out a way based on the tools I have, or do I ask someone else?
Well, you have the tools! And that's what's fun about programming. Having something that needs (or you want) to be done and formulating an approach based on what's available to you as a programmer. So, rather then just tell you, I'll give you a hint or two.
Use an array.
Use a loop.
sizeof() is your friend.
The "." operator is your friend.
Hate me yet!?
Later on,
BDKR
Well, you have the tools! And that's what's fun about programming. Having something that needs (or you want) to be done and formulating an approach based on what's available to you as a programmer. So, rather then just tell you, I'll give you a hint or two.
Use an array.
Use a loop.
sizeof() is your friend.
The "." operator is your friend.
Hate me yet!?
Later on,
BDKR
but seriously, no, if the user entered <"white tennis shoes"> (without the carets) then that would not be a match, becuse they'd be searching for that exact string.
if they entered <white tennis shoes>, then I would want that to be a match and would explode() the terms and search for them.
that's what i was trying to say in my last post, but it wasn't very clear