在我的数据库中,有些天有数据,有些天没有;我有一列包含数据,另一列包含提交的日期和时间。所以我想创建这个日历。所以它会显示一个月中的所有天数,然后有数据的天数将是一个超链接。
当我点击链接时,它会显示当天提交的所有数据。我可能会在第一个循环中使用一个循环。一个用于一个月,然后一个用于显示每一天。
但是,由于一年中每个月的天数不同,而且闰年也是一个问题,我不知道如何写条件。
感谢任何帮助或指导。
最佳答案
$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/