2000points myslquery?

Discussion in 'PHP' started by izlik, Dec 22, 2007.

  1. #1
    Hello, i have this code bellow on my gaming site wich is a part of a cron query wich is supposed to give the top users of the day with the most points special features for the next day, i have now decided to do the same for people earning 2000 points each day, so i wonder the queary bellow,

    how would this code look like if i wanted it it to search the collumn "today_points" for users with 2000 points or above only? and give them the the same resault as "$update_user" and "$update_status" ?


    $sql = mysql_query("SELECT fid FROM fc_users ORDER BY today_points DESC LIMIT 1") or die (mysql_error());
    $result = mysql_fetch_array($sql);
    
    $update_user = mysql_query("update fc_users set featured_profile = featured_profile + 2 where fid = " . $result["fid"] . " limit 1") or die (mysql_error());
    
    $update_status = mysql_query("update fc_users set featured_status = 1 where fid = " . $result["fid"] . " limit 1") or die (mysql_error()); 
    PHP:
     
    izlik, Dec 22, 2007 IP
  2. matthewrobertbell

    matthewrobertbell Peon

    Messages:
    781
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #2
    
    mysql_query("update fc_users set featured_status = 1 where today_points > 2000") or die (mysql_error());
    
    mysql_query("update fc_users set featured_status = 0 where today_points < 2000") or die (mysql_error());
    
    PHP:
    The second one is to stop users who used to have more than 2000 points still getting featured status.
     
    matthewrobertbell, Dec 22, 2007 IP
  3. izlik

    izlik Well-Known Member

    Messages:
    2,399
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    185
    #3

    thanks! :)

    but how do you mean, with the second one, if they recived 2000 points they wont get it a second time ? if yes, they points reset every 24hours.

    is it possible to make the query set this status to users who have 2000 and up to 2500 points only?
     
    izlik, Dec 22, 2007 IP
  4. lfhost

    lfhost Peon

    Messages:
    232
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #4
    
    mysql_query("update fc_users set featured_status = 1 where today_points BETWEEN 2000 AND 2500") or die (mysql_error());
    mysql_query("update fc_users set featured_status = 0 where today_points < 2000") or die (mysql_error());
    
    Code (markup):
     
    lfhost, Dec 22, 2007 IP