<?
//顯示月曆開始
if ($_POST['addY']){
$addY=$_POST['addY'];
}else{
$addY=date(Y);
}
if ($_POST['addM']){
$addM=$_POST['addM'];
}else{
$addM=date(m);
}
$t=date(t,mktime(0,0,0,$addM,1,$addY));
$w=date(w,mktime(0,0,0,$addM,1,$addY));
$F=date(F,mktime(0,0,0,$addM,1,$addY));
echo "<table align=center border=0><tr align=center><td><font size=5 color=999999><b>";
echo $yearYM=$F." ".$addY;
echo "</b></td></tr><tr align=center><td> </td></tr></table>";
echo "<table align=center border=0>";
echo "<tr align=center height=40>
<td><font color=red><b>Sun</b></td>
<td><b>Mon</b></td>
<td><b>Tue</b></td>
<td><b>Wed</b></td>
<td><b>Thu</b></td>
<td><b>Fri</b></td>
<td><font color=green><b>Sat</b></td>
</tr>";
if ($w > 1) {
echo "<tr>";
for ($i=1; $i<=$w-1; $i++) {
echo "<td align=center width=40></td>";
}
}
for ($i=$w; $i<=$w+$t; $i++) { //$w+$t=35
//一週七天
if ($i%7==1){
echo "<tr><td align=center width=40>";
}else{
echo "<td align=center width=40>";
}
if ($i-$w > 0) {
echo "<font size=5><b>";
//echo $i-$w;
echo "<a href=".($i-$w).">".($i-$w)."</a>";
echo "</b></font>";
}else{
echo " ";
}
if ($i%7==0){
echo "</td></tr>";
}else{
echo "</td>";
}
}
if ($i%7==0) {
echo "<td width=40> </td>";
}elseif ($i%7==1) {
echo "";
}elseif (($i%7)>0) {
for ($j=$i; $j<=$i+7; $j++) {
if (($j%7)==0) {
echo "<td width=40> </td>";
break;
}else{
echo "<td width=40> </td>";
}
}
echo "</tr>";
}
echo "</table>";
//顯示月曆結束
?>
<form method=post name=form1 id=form1 enctype="multipart/form-data" action="" onsubmit="submitbutton();">
<table align=center border=0><tr align=center><td><font size=5 color=999999>
<tr><td align=right></td><td><b>顯示月份 :</b>
<input size=4 type="text" name="addY" value="<?echo $addY?>"><b>年</b>
<b>
<select name="addM" size="1">
<?php
for ($temp=1;$temp<=12;$temp++){
if ($temp==$addM){
?>
<option selected><?php echo $temp;?></option>
<?php }else{?>
<option><?php echo $temp;?></option>
<?php }
}
?>
</select>
月</b> </td>
</tr>
<tr><td align=center colspan=2>
<input type="submit" name="submitbtn" value="顯示">
</td></tr>
</table>
<p>最下面的表單部分,您也可以改成下拉式表單
或是根本不用表單,直接做成下拉式連結就更方便
包括視覺效果您也可以自己改變
就像是這樣 http://www.tenway.com.tw/memberList/ (左邊會員登入的下面)
上面的程式碼做出來的效果就像這樣
http://works.sdcs.com.tw/Imgck/makeCalendar4.php </p>
<p> </p>
<form name="form1" method="post" action="">
</form>
<p> </p>
資料來源:因忘了在那找的,所以無來源,但版權為原作者所有!
沒有留言:
張貼留言