<?php
header("Content-type:text/html;charset=utf-8;");
$year = date ( 'Y' ); //获得年份, 例如: 2006
$month = date ( 'n' ); //获得月份, 例如: 04
$day = date ( 'j' ); //获得日期, 例如: 3
$firstDay = date ( "w", mktime ( 0, 0, 0, $month, 1, $year ) );
//获得当月第一天
$daysInMonth = date ( "t", mktime ( 0, 0, 0, $month, 1, $year ) );
//获得当月的总天数
//echo $daysInMonth;
$tempDays = $firstDay + $daysInMonth; //计算数组中的日历表格数
$weeksInMonth = ceil ( $tempDays/7 ); //算出该月一共有几周(即表格的行数)
//创建一个二维数组
for($j = 0; $j < $weeksInMonth; $j ++) {
for($i = 0; $i < 7; $i ++) {
$counter ++;
$week [$j] [$i] = $counter;
//offset the days
$week [$j] [$i] -= $firstDay;
if (($week [$j] [$i] < 1) || ($week [$j] [$i] > $daysInMonth)) {
$week [$j] [$i] = "";
}
}
}
?>
<script type="text/JavaScript" src="calendar.js"></script>
<style>
table {border-right: solid 1px #999; border-bottom: solid 1px #999; }
table tr th{border: solid 1px #999; padding: 10px; border-bottom: none; border-right: none;}
table tr td{border: solid 1px #999; padding: 10px; border-bottom: none; border-right: none;}
table tr td select{border: none;}
</style>
<table width="400" border="0" cellpadding="0" cellspacing="0">
<tr>
<th colspan='7'>
<?php
echo "今天是 ".date ( 'Y-m-d', time() ) ;
?>
</th>
</tr>
<tr>
<th>日</th>
<th>一</th>
<th>二</th>
<th>三</th>
<th>四</th>
<th>五</th>
<th>六</th>
</tr>
<?php
foreach ( $week as $key => $val ) {
echo "<tr>";
for($i = 0; $i < 7; $i ++) {
echo "<td align='center'>" . $val [$i];
if($val [$i]!=''){
echo "<select name='arrange'><option value='1'>全天出诊</option><option value='1'>上午出诊</option><option value='1'>下午出诊</option></select></td>";
}
}
echo "</tr>";
}
?>