php - 如何用MYSQL数据制作日历?

标签 php mysql

在我的数据库中,有些天有数据,有些天没有;我有一列包含数据,另一列包含提交的日期和时间。所以我想创建这个日历。所以它会显示一个月中的所有天数,然后有数据的天数将是一个超链接。

当我点击链接时,它会显示当天提交的所有数据。我可能会在第一个循环中使用一个循环。一个用于一个月,然后一个用于显示每一天。

但是,由于一年中每个月的天数不同,而且闰年也是一个问题,我不知道如何写条件。

感谢任何帮助或指导。

最佳答案

$start = '2009-01-01';
$current = strtotime($start);
while(date('n',$current)==date('n',strtotime($start))) {
    // do your stuff here, $current includes the current date.
    // the loop will run through the complete month

    $current = strtotime(date('Y-m-d',$current) . '+1 day');
}

关于php - 如何用MYSQL数据制作日历?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1402202/

相关文章:

mysql - 优化表后,Wordpress/MySQL (InnoDB) 表几乎瞬间碎片化?

mysql - Node.js 服务器是否应该与 mysql 实例有一个连接?

mysql - 如何在 MySQL 中同时更新和选择

php - 使用 Visual Studio 2008 编译 php 扩展,MODULE ID 与 php 不匹配

PHP PDO 超时

php - 如果运送方式更改,则隐藏结账页面上的自定义字段

php - 使用 codeIgniter 查询多个数据库

mysql - 根据标识符和来自另一行的值选择行

php - 在特定时间从数据库中删除一行

php - 在数据库中上下移动行