返回列表 回復 發帖

請問: 如何在php月曆加上其他月份呢???

我寫在個php 月曆 但只能show current month .如果我想加返 2008 and 2009 年 1月到12 月 係個月曆低部我需要點做呢... 以下係我個php code

唔該幫幫我呀 thanks

------------------------------

<!DOCTYPE html public"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://w3.org/TR/xhtml1/DTD/xhtml1-trnsitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link rel="stylesheet" href="abcd.css" type="text/css" />
</head>
<body>

<?php
print( '<a href=2a.php><h1>Date:</h1></a>' );
print strftime('%D');
$date =time ();
$day = date ('d', $date);
$month = date('m', $date);
$year = date('Y', $date);
$first_day = mktime(0,0,0,$month, 1, $year);
$Mon_day= date('F', $first_day);
$daysofweek = date('D',$first_day);
define("CAL_GREGORIAN", true);
switch($daysofweek)
{
case"Sun": $blank = 0;
break;
case"Mon": $blank = 1;
break;
case"Tue": $blank = 2;
break;
case"Wed": $blank = 3;
break;
case"Thu": $blank = 4;
break;
case"Fri": $blank = 5;
break;
case"sat": $blank = 6;
break;
}
$today = date("D, m d Y");
echo"<table border=10 width=450 cellpadding=30>";

echo "<tr><th class='calendar' colspan=7> $Mon_day $year </th></tr>";
echo "<tr><td width=70>SUN</td><td width=70>MON</td><td width=70>TUE</td><td width=70>WED</td>
<td width=70>THUR</td><td width=70>FRI</td><td width=70>SAT</td>";

$day_count= 1;
function days_in_month($month, $year)
{
if(checkdate($month, 31, $year)) return 31;
if(checkdate($month, 30, $year)) return 30;
if(checkdate($month, 29, $year)) return 29;
if(checkdate($month, 28, $year)) return 28;
return 0;
}
$daysInMonth = days_in_month(CAL_GREGORIAN,$month, $year);

echo "<tr>";
while
( $blank > 0)
{
echo "<td></td>";
$blank = $blank-1;
$day_count++;
}
$dayn =1;
while
( $dayn <= $daysInMonth )
{
echo "<td> $dayn </td>";
$dayn++;
$day_count++;
if ($day_count >7)
{
echo "</tr><tr>";
$day_count =1;
}
}
while
($day_count > 1 && $day_count <= 7)
{
echo "<td></td>";
$day_count++;
}
echo "</tr></table>";
?>
</body>
</html>
there is many php calendar free tutorials.. U should google it..
I remember i found it last time and used it b4..
寻找到独一无二的自己。。。
見到不過d function 同自己個php 有error 甘你可唔可以 upload 你個 月曆比我睇下
返回列表