我有一个设置在mySQL表中的日历,我试图通过每月日历输出日期(Jan, 2月,3月),其中包括前几个月和下一个月的“失踪日”。在每个月的开始/结束时显示占位符空间的日历(日月,星期几)
因此,如果我想为2013年1月和1月1日制作一个日历 - 我无法编写一种方法来显示Sun Dec 30和Mon Dec 31充当“空间填充”或什么你有...知道我的意思吗?
我有困难的时间围绕如何输出这些信息。
的数据结构和数据如下:
TABLE_NAME:sched_calendar_table
dt y q m d dw monthName dayName w isWeekday isHoliday holidayDescr isPayday
2010-01-01 2010 1 1 1 6 January Friday 0 1 1 New Year's Day 0
2010-01-02 2010 1 1 2 7 January Saturday 0 0 0 0
2010-01-03 2010 1 1 3 1 January Sunday 1 0 0 0
2010-01-04 2010 1 1 4 2 January Monday 1 1 0 0
2010-01-05 2010 1 1 5 3 January Tuesday 1 1 0 0
我计划创建使用表的每个月历。
因此,代码的开始部分是:
echo '<table>';
$sql="SELECT * FROM sched_calendar_table WHERE y=2013";
$result=mysql_query($sql);
while($row=mysql_query($result)){
echo '<tr><td>'; // .. unsure how to account for the placeholder days that aren't part of the month being displayed... how to do this?
}
echo '</table>';
我已经回答了类似的问题> http://stackoverflow.com/questions/12317909/find-weekly-periods-starting-on-a-monday-for-a-month/12324474#12324474 –
The' mysql'-extension已过时,不再维护,并且将被标记为已弃用PHP5.5。改为使用'PDO_MYSQL'或'MySQLi'。请参阅http://php.net/mysql-connect – KingCrunch
[**请勿在新代码**中使用'mysql_ *'函数](http://bit.ly/phpmsql)。他们不再被维护[并被正式弃用](https://wiki.php.net/rfc/mysql_deprecation)。看到[**红框**](http://j.mp/Te9zIL)?学习[*准备的语句*](http://j.mp/T9hLWi),并使用[PDO](http://php.net/pdo)或[MySQLi](http://php.net/ mysqli) - [这篇文章](http://j.mp/QEx8IB)将帮助你决定哪个。如果你选择PDO,[这里是一个很好的教程](http://j.mp/PoWehJ)。 –