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;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作