Can you help?

Discussion in 'Databases' started by Marty Rogers, Apr 19, 2007.

  1. #1
    I have this code:

    $sql = 'SELECT ref, name, pic, id, count, real_count, out, real_out FROM links
    	ORDER BY count DESC LIMIT '.$config['display_num'];
    Code (markup):
    I would like it to select them WHERE my field 'count' is a number more than 5. Can i do this, anyone know what i need to add? I use this script for top referrers list on my site, i only want referrers to show who have sent me 5 hits you see...
     
    Marty Rogers, Apr 19, 2007 IP
  2. bochgoch

    bochgoch Peon

    Messages:
    1,918
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try:

    
    $sql = 'SELECT ref, name, pic, id, count, real_count, out, real_out FROM links
            WHERE count > 5
    	ORDER BY count DESC LIMIT '.$config['display_num'];
    
    Code (markup):
     
    bochgoch, Apr 19, 2007 IP
  3. Marty Rogers

    Marty Rogers Guest

    Messages:
    596
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yepp, that works great - thankyou!
     
    Marty Rogers, Apr 19, 2007 IP
  4. Marty Rogers

    Marty Rogers Guest

    Messages:
    596
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Can anybody else help me with this one then?

    I'd like it to select WHERE the number in the field 'count' is no more than 20 less than the number in my field 'out' - so if i've sent them alot more traffic than they've sent me, i want to stop displaying their link when i send them 20 more hits than they've sent me.

    Anybody know how i could do this? Appreciate the help.
     
    Marty Rogers, Apr 20, 2007 IP
  5. officialboss

    officialboss Peon

    Messages:
    17
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Try this:
    $sql = 'SELECT ref, name, pic, id, count, real_count, out, real_out FROM links
            WHERE count > 5 OR Count =< 20
    	ORDER BY count DESC LIMIT '.$config['display_num'];
    Code (markup):
     
    officialboss, Apr 21, 2007 IP
  6. Marty Rogers

    Marty Rogers Guest

    Messages:
    596
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Nope that didn't work eek :(
     
    Marty Rogers, Apr 21, 2007 IP
  7. Marty Rogers

    Marty Rogers Guest

    Messages:
    596
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Can anybody with these, please? I really need it.

    Don't want to show sites that have sent me 30 hits less than i've sent them.
     
    Marty Rogers, Apr 21, 2007 IP
  8. micmic

    micmic Well-Known Member

    Messages:
    95
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    113
    #8
    Hi,
    Try "AND" insted of "OR"....
    I believe that should work
     
    micmic, Apr 23, 2007 IP
  9. kernes

    kernes Peon

    Messages:
    184
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Try this:
    Code:

    $sql = 'SELECT ref, name, pic, id, count, real_count, out, real_out FROM links
    WHERE count > 5 and Count =< 20
    ORDER BY count DESC LIMIT '.$config['display_num'];
     
    kernes, Apr 24, 2007 IP
  10. asfi

    asfi Peon

    Messages:
    110
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Hi,
    Try for this

    $sql = 'SELECT ref, name, pic, id, count, real_count, out, real_out FROM links
    ORDER BY count>=5 DESC LIMIT '.$config['display_num'];
     
    asfi, Apr 24, 2007 IP