SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Mar 2004
    Location
    Europe
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can you order wildcard results by closest match?

    I want to search my DB using the string:

    if ($search_title){$newsql=$newsql . " AND books.title = '" . $search_title ."'";}

    but I need to use wildcards somehow to allow the user to enter the initial part of the book title if they don't know the full title.

    How do I do it and how do I order the results by relevance/matching to the original. I'm already going to order the results alphabetically.

  2. #2
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can do "... AND books.title LIKE 'Lord of%' ORDER BY books.title"

    See: LIKE from http://dev.mysql.com/doc/mysql/en/St...functions.html
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy


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
  •