본문 바로가기

Story/php

PEAR 를 이용하여 달력 만들기

반응형

require_once "Calendar/Month/Weekdays.php";
// 달력그리기
$Month = & new Calendar_Month_Weekdays(date("Y"), date("m"),0);
$Month->build();
echo "<table>";
while ($Day = & $Month->fetch()) {
    $cal_viewday=$Day->thisDay();
    if(date("d",$viewday)==$cal_viewday) $bgcolor=" bgcolor=F3F3F3 ";
    elseif(date("Ymd")==date("Ym".$cal_viewday,$viewday)) $bgcolor=" bgcolor=C2C6CA ";
    else $bgcolor="";
    if($Day->isFirst()) echo "<tr>";
    if($Day->isEmpty()) echo " <td width=22 height=20 align=center><font size='-2'></font></td>";
    else echo " <td width=22 height=20 align=center $bgcolor><a href=''><font size='-2' color=000000>".$cal_viewday."</font></a></td>";
    
    if($Day->isLast())
        echo "</tr>";
}
echo "</table>";
반응형