Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13
  1. #1
    Senior Member
    Join Date
    Aug 2011
    Posts
    227
    Member #
    29153
    Liked
    4 times
    For example, if someone does a search for "abcde" and I want to find every record that has "abcde" anywhere in it, how to I find that record?

  2.  

  3. #2
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,715
    Member #
    5580
    Liked
    717 times
    Searching what? A MySQL database table, a text file, an array, a string?


  4. #3
    Senior Member
    Join Date
    Aug 2011
    Posts
    227
    Member #
    29153
    Liked
    4 times
    I'm using php searching a MySQL database.

  5. #4
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,485
    Member #
    425
    Liked
    2783 times
    WHERE [field] LIKE '%whatever your term is%'
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  6. #5
    Senior Member
    Join Date
    Aug 2011
    Posts
    227
    Member #
    29153
    Liked
    4 times
    What if it's 2 words and the 2 words aren't together in the string? For example,the search is "nike shoe". If a record has "nike shoes" or "shoes like Adidas and Nike". Notice the upper and lower cases also.

  7. #6
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,485
    Member #
    425
    Liked
    2783 times
    I don't know how to do a case-sensitive search in MySQL, or if it's even possible.

    But you can easily enough modify that query to read:

    WHERE [field] LIKE '%nike%' and [field] LIKE '%adidas%'
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  8. #7
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,715
    Member #
    5580
    Liked
    717 times
    MySQL is not case-sensitive.
    To force it, you need to specify BIN (binary) for a byte-by-byte match.
    So you're OK with the cases.


  9. #8
    Senior Member
    Join Date
    Aug 2011
    Posts
    227
    Member #
    29153
    Liked
    4 times
    Quote Originally Posted by mlseim, post: 225025
    MySQL is not case-sensitive.
    To force it, you need to specify BIN (binary) for a byte-by-byte match.
    So you're OK with the cases.
    So, if a user searches "nike" it will find "Nike"? Keep in mind it's a Linux server.

  10. #9
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,715
    Member #
    5580
    Liked
    717 times
    That is correct.
    If I'm wrong, please let me know.

    nIKe
    NiKE
    NIKE
    nikE

    should all work.


  11. #10
    Senior Member
    Join Date
    Aug 2011
    Posts
    227
    Member #
    29153
    Liked
    4 times
    How would I search for an unknown number of words. Say a user searches "nike shoe" and the next searches "red nike shoe"? What I'm trying to do here is create a search after "explode" function. I can't distinguish LIKE $word[1] AND LIKE $word[2] ...etc when I do not know how many words may be entered.


Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 07:27 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com