SitePoint Sponsor |
|
User Tag List
Results 1 to 5 of 5
-
Nov 6, 2000, 04:01 #1
- Join Date
- Jul 2000
- Location
- Nowhere
- Posts
- 278
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
anyone know a function (built-in) in PHP to search a mySQL table for a word or phrase? I know this bulletin board has a search function but how can I program this and make somekind of ranking for the results?
thanx
-
Nov 6, 2000, 07:47 #2
- Join Date
- Aug 1999
- Location
- East Lansing, MI USA
- Posts
- 12,937
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
SELECT *
FROM TABLE
WHERE desiredcolumn like '%searchcriteria%'
Chris
-
Nov 6, 2000, 11:21 #3
- Join Date
- Jul 2000
- Location
- Nowhere
- Posts
- 278
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
It works fine without problems, however not very precise...
for example the words: 'but', 'and', 'in' etc. are almost in every tip of the day. I know, one should search for such words, but can I somehow make the search more precise? When I entered a space (spacebar), all tips were shown which I hope to prevent.
thanks alot in advance!
-
Nov 6, 2000, 11:28 #4
- Join Date
- Aug 1999
- Location
- East Lansing, MI USA
- Posts
- 12,937
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Yes, that is very basic.
But many search functions work that way.
People will not be searching for "and" or "the" they'll be searching for more complicated words or phrases. If you type in "The" in lycos and you'll get a quarter of a billion results. The only way other search engines get around this is by simply denying the ability to search by such common single words.
As for the space, you can trim the search input and then do a check and see if it contains anything, if it does not don't let them search.
If you want them to be able to search for:
"White House" +carter -nixon
Then you're going to have to take the search input, parse it and break it into different variables, and then reconstruct your search statement.
Chris
-
Nov 6, 2000, 11:39 #5
- Join Date
- Aug 2000
- Location
- San Diego, CA
- Posts
- 5,460
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I wrote one a while back, that checks for the existence of 'and' or 'or' in the serach string then builds the query accordingly while omitting those two words from the search. if you would like a copy of the code just email me at freddy@bereminded.com and I would be happy to give you a copy.
Please don't PM me with questions.
Use the forums, that is what they are here for.
Bookmarks