dtng5978 2011-09-02 14:12
浏览 40
已采纳

每日/每周/每月高分榜

I have an online highscores made with php + mysql but it currently shows the All Time highscores, I want to add Daily/Weekly/Monthly to that and I was wondering what would be the best way todo that?

My current thought is to add 3 new tables and then have the data inserted into each of them, and then having a cron which would run at the appropriate times to delete the data from each of the tables.

Is there any better way I could do this?

Another thing, I want to have it so the page would be highscores.php?t=all t=daily, etc. How would I make it so that the page changed the query depending on that value?

Thanks.

  • 写回答

1条回答 默认 最新

  • douyun6399 2011-09-02 14:15
    关注

    Use one table and add a column with the date of the highscore. Then have three different queries for each timespan, e.g.

    SELECT ... FROM highscores WHERE date>"05-12-2011";
    

    If you want to have a generic version without the need to have a fixed date, use this one:

    SELECT ...
    FROM highscores
    WHERE date >= curdate() - INTERVAL DAYOFWEEK(curdate())+6 DAY;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?