php sql, count and update?

Discussion in 'PHP' started by izlik, Nov 25, 2007.

  1. #1
    Hey there.

    I was wondering if someone could help me here with a php sql part i cant understand how to make.

    i run a pointbased page where users get's points for diffrent things, and they are reseted every day, now i wonder how can i make it so that each night when the reset happens, it counts who have the most points for the row "totaltoday" and updates the row "vip" to +1 ? if it's 0 it should be 1, if it's 1 it should be 2 etc.

    hope someone can help me
    thanks in advance.
     
    izlik, Nov 25, 2007 IP
  2. live-cms_com

    live-cms_com Notable Member

    Messages:
    3,128
    Likes Received:
    112
    Best Answers:
    0
    Trophy Points:
    205
    Digital Goods:
    1
    #2
    UPDATE `table` SET `vip` = `vip`+1 WHERE `totaltoday` = (SELECT MAX(`totaltoday`) FROM `table`)

    That was off the top of my head so it could be incorrect.
     
    live-cms_com, Nov 25, 2007 IP