複製程式
<?
$week = array ( //以陣列設定週日~週六
0 => "週日",
1 => "週一",
2 => "週二",
3 => "週三",
4 => "週四",
5 => "週五",
6 => "週六");
$month = ($month=="") ? date("m"):"$month"; // 月份
$year = ($year=="") ? date("Y"):"$year"; // 年份
$today = ($today=="") ? date("d"):"$today"; //日期
$m_days = date("t", mktime(0, 0, 0, $month, 1, $year)); //判斷每個月有幾天
$day = date( "w", mktime(0, 0, 0, $month, 1, $year)); //判斷每個月1號是星期幾
?>
<style>
table{font-size:9pt}
</style>
<table>
<tr bgcolor=99CCFF > <? echo "現在是 $year 年 $month 月"; ?>
<?
for ($i=0 ; $i<=6 ; $i++)
echo "<td bgcolor=#6699CC><font color=white>$week[$i]</font></td>";
?>
</tr>
<?
if ($day == 0 ) { //若1號是星期天,$day的值會是0
$day = 7 ; //將星期天的值改成7
}
$day = 1-$day ;
while($day <= $m_days) {
?>
<tr>
<?
for ($td=0; $td<=6; $td++){
if ($day <= $m_days && $day > 0) {
echo "<td bgcolor=#6699FF><font color=white>$day</font></td>";
}else{
echo "<td bgcolor=red> </td>";
}
$day++;
}
?>
</tr>
<?
}
?>
</table>
有興趣可以參考一下
感覺自己寫的好亂 =_=
想問看看還有誰寫過的