Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2004
    Location
    Sweden
    Posts
    68

    Search engine suggestions

    Hiya
    I have built a search engine for game cheats and im not really happy with it just yet.
    Currently it does like this when trying to find results

    PHP Code:
    $trimmed trim($var); //trim whitespace from the stored variable

    $query "select * from cheatcc_com_pc where cheatcategory='$Category' AND title like \"%$trimmed%\"  
      order by title"

    and id say that pretty much blows the way it checks so i wonder if someone knows a better solution.
    Like lets say i have a game named "trevor likes: oranges"
    and i search for "trevor likes oranges" without the : .
    It doesnt find it at all in the database.

    Anyone got better ideas?



    Best Regards
    Jawn

  2. #2
    Join Date
    Oct 2003
    Location
    Israel
    Posts
    132
    Try this:

    PHP Code:
    $trimmed ereg_replace(":"" "trim($var));

    $query mysql_query("SELECT * FROM cheatcc_com_puc
                                          WHERE cheatcategory = '
    $Category'
                                          AND title LIKE '%
    $trimmed%'"); 
    Last edited by Tomer; 07-17-2005 at 11:03 AM.
    Christmas time is among us, get your loved ones Designer Fragrances

  3. #3
    Join Date
    Oct 2003
    Location
    Israel
    Posts
    132
    please delete this.
    Christmas time is among us, get your loved ones Designer Fragrances

  4. #4
    Join Date
    Sep 2004
    Location
    Sweden
    Posts
    68

    Re: Search engine suggestions

    Originally posted by Fallzone
    Hiya
    I have built a search engine for game cheats and im not really happy with it just yet.
    Currently it does like this when trying to find results

    PHP Code:
    $trimmed trim($var); //trim whitespace from the stored variable

    $query "select * from cheatcc_com_pc where cheatcategory='$Category' AND title like \"%$trimmed%\"  
      order by title"

    and id say that pretty much blows the way it checks so i wonder if someone knows a better solution.
    Like lets say i have a game named "trevor likes: oranges"
    and i search for "trevor likes oranges" without the : .
    It doesnt find it at all in the database.

    Anyone got better ideas?



    Best Regards
    Jawn
    You see that wont work since the search engine is going by title name in the database.
    $trimmed is the var of the search string.
    Maybe i didnt post enough info sorry

    Best Regards
    Jawn

  5. #5

    Re: Search engine suggestions

    Originally posted by Fallzone
    [B]Hiya
    I have built a search engine for game cheats and im not really happy with it just yet.
    The best you can do is to use FULLTEXT search.
    Fulltext search provides you with search options like when you're searching Google's database (you can exclude terms and so on).

    Basically, you have to modify your varchar, char and text fields that you want to search and add them a FULLTEXT index (alter table tablename add fulltext(columname)).
    That will create a FULLTEXT index.
    I'll take your table for FULLTEXT search example.

    PHP Code:
    $query "SELECT * FROM cheatcc_com_puc WHERE cheatcategory = '$Category' AND MATCH(title) AGAINST ($trimmed)"
    You specify column list in "MATCH" and AGAINST is word list or a phrase you're searching for.
    Googling "mysql fulltext search" will give you lots of resources where you can see more advanced examples which will help you achieve better search results.

    Also, fulltext searching is faster than using LIKE but that's not what we're debating upon here.
    Good luck.

Posting Permissions

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