复制程式
<?
$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>
有兴趣可以参考一下
感觉自己写的好乱 =_=
想问看看还有谁写过的