2007-01-04, 04:58 PM
|
#3 (permalink)
|
協調管理員
|
以下是我的php寫法
PHP 語法:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>萬年曆</title>
<!--不要給proxy cache圖片-->
<meta http-equiv="expires" content="0">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="pragma" content="no-cache">
<!--不要給proxy cache圖片結束-->
<base target="_self">
</head>
<body topmargin="0" leftmargin="0">
<div align="left">
<table border="0" width="95%" id="table3" cellspacing="0" cellpadding="0" bgcolor="#78AEFF">
<tr>
<td width="100%" align="center">
<?
if(isset($_GET['year'])){$year=$_GET['year'];}else{$year=date("Y");}
if(isset($_GET['mon'])){$mon=$_GET['mon'];}else{$mon=date("m");}
$mon=$mon;
if ($mon == 1 ||$mon == 3 ||$mon == 5||$mon == 7||$mon == 8||$mon == 10||$mon == 12){ $stop=31;
}elseif($mon == 4||$mon == 6||$mon == 9||$mon == 11){ $stop=30;
}else{
if ($year % 4 > 0){$stop=28;}else{$stop=29;}
}
for ($i=1;$i<=$stop;$i++){
//計算星期開始
if ($mon == 1){$mm=0;}
if ($mon == 2){$mm=31;}
if ($mon == 3){$mm=59;}
if ($mon == 4){$mm=90;}
if ($mon == 5){$mm=120;}
if ($mon == 6){$mm=151;}
if ($mon == 7){$mm=181;}
if ($mon == 8){$mm=212;}
if ($mon == 9){$mm=243;}
if ($mon == 10){$mm=273;}
if ($mon == 11){$mm=304;}
if ($mon == 12){$mm=334;}
$mmod=($year - 1) / 4;
$yyod=($year - 1) * 365;
$eeee=($mm+$mmod+$yyod+$i);
$PPP=$eeee % 7;
//$textt是要顯示的顏色,六日都是顯示灰色
if ($PPP == 1){$week[$i]=$PPP;}//星期日
elseif($PPP == 2){$week[$i]=$PPP;}//星期一
elseif($PPP == 3){$week[$i]=$PPP;}//星期二
elseif($PPP == 4){$week[$i]=$PPP;}//星期三
elseif($PPP == 5){$week[$i]=$PPP;}//星期四
elseif($PPP == 6){$week[$i]=$PPP;}//星期五
elseif($PPP == 0){$week[$i]=$PPP;}//星期六
else{$week[$i]='';}
}
while($i<=42){$week[$i]='';$i++;}
$j=1;
for ($i=1;$i<=42;$i++){
if (($i)%7 == $week[$j]){
if($j<=$stop){
$where[$i]=$j;
$j++;
}else{
$where[$i]='';
}
}else{
$where[$i]='';
}
}
?>
<? print "<a href=\"xx.php?year=$year&mon=$mon";
if (isset($_GET['edit'])){print "&edit=";}
print "\"><b>$year 年$mon 月</b></a><br>";
?>
<table border="1" id="table4" cellspacing="1" cellpadding="0">
<tr>
<td><b><font size="4">日 </font></b> </td>
<td><b><font size="4">一 </font></b> </td>
<td><b><font size="4">二 </font></b> </td>
<td><b><font size="4">三 </font></b> </td>
<td><b><font size="4">四 </font></b> </td>
<td><b><font size="4">五 </font></b> </td>
<td><b><font size="4">六 </font></b> </td>
</tr>
<?
$wk=1;
for($k=0;$k<=5;$k++){
print "<tr>";
for($m=1;$m<=7;$m++){
print "<td>";
if (isset($_GET['edit'])){print "&edit=";}
print "$where[$wk]</td>\n\t";$wk++;}
print "</tr>";
}
?>
</table>
</td>
|
__________________
|
|
送花文章: 11706,
收花文章: 3363 篇, 收花: 16453 次
|