SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Evangelist jazztie's Avatar
    Join Date
    Mar 2001
    Location
    the Netherlands
    Posts
    519
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Searching for ""

    I'm currently working on a search engine for my website.
    To allow people to search with multiple words I have written the following code:
    PHP Code:
    $keywords_sep explode(" "$keywords);    
    foreach(
    $keywords_sep AS $keyword){     
       
    $KeyQuery mysql_query("SELECT * FROM page WHERE (Keywords LIKE '%$keyword%') OR (Title LIKE '%$keyword%') ORDER BY Title"); 
    Pretty straight forward. But I also want to allow the user to enter "'s so it can search for a exact match of a couple of words.

    i.e. If you look for Higher Education, in the sample above it gives every page with Higher AND/OR Education. Maybe this user doesn't want to find a page about Kindergarden Education... but it will show up, because one of the keywords is in it.

    Now, if someone is searching for Higher Education, he/she should / could add " to the search. i.e. "Higher Education".

    Now my question is: How do I check in my search-variable for any occurance of a word between ""? And how do I get it in a separate variable?

    Any help is appreciated!
    Jazz

  2. #2
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Which version of MySQL will this run on?

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  3. #3
    SitePoint Evangelist jazztie's Avatar
    Join Date
    Mar 2001
    Location
    the Netherlands
    Posts
    519
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It runs on MySQL (Client API version): 3.23.39
    and PHP version: 4.2.3

  4. #4
    SitePoint Evangelist jazztie's Avatar
    Join Date
    Mar 2001
    Location
    the Netherlands
    Posts
    519
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Correction:
    MySQL version: 3.23.56

  5. #5
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was going to suggest looking at fulltext indexing if it was a 4* version

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature


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
  •