SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    Almeaty Member
    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

  2. #2
    Serial Publisher silver trophy aspen's Avatar
    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

  3. #3
    Almeaty Member
    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!

  4. #4
    Serial Publisher silver trophy aspen's Avatar
    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

  5. #5
    Dumb PHP codin' cat
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •