Search by number range

Discussion in 'PHP' started by audax, Apr 16, 2009.

  1. #1
    Hi folks!

    I'm having trouble figuring out how to go about a problem I've run into. What I'm trying to do is have a search script that searches by number range for a number range. What I'm trying to do is have a search by age range script that searches a database for all entries that have a number range that is in the range searched. I'm not sure if that makes sense, but let me give an example.

    A person in my database has an age range of what they appear to look like. For instance, one person might be twenty years old but they look like they're anywhere from 17 to 24. The search script would be able to search for ranges from 13-17, 18-20, 21-25, or something along those lines. This would mean that this person would appear in three different results pages. Or, another option might be that the user doing the search enters in an age range that they desire and the right people would show up in the results page. Is this feasible? How would I go about it? Would MySQL's BETWEEN query option be appropriate? I'm not quite sure how to go about this. Any ideas? I haven't built the fields in the MySQL database yet, so it's flexible to be whatever.
     
    audax, Apr 16, 2009 IP
  2. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #2
    where age >= 13 and age <= 17
     
    SmallPotatoes, Apr 16, 2009 IP
  3. KRISHNA KUMAR

    KRISHNA KUMAR Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You can also use like that.

    select * from `abc`
    where `age` between(min, max);
     
    KRISHNA KUMAR, Apr 16, 2009 IP
  4. fourfingers

    fourfingers Peon

    Messages:
    37
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    ^^ THIS

    greetings from WF
     
    fourfingers, Apr 17, 2009 IP
  5. audax

    audax Peon

    Messages:
    83
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Oh! Duh. Thanks! I wasn't even thinking straight haha.

    Thanks for your advice. I'll go ahead and use that.
     
    audax, Apr 20, 2009 IP