Category
show
전체 (775)
웹표준, 웹접근성™ (5)
웹프로그래밍™ (360)
웹기획™ (0)
웹디자인™ (5)
서버™ (32)
데이터베이스™ (43)
개발자료 (9)
트랜드 (60)
Study English (2)
블루비 (70)
오피스 다이어리 (19)
Textcube (2)
이슈 (20)
컴퓨터 악세사리 (18)
엔터테인먼트 (24)
좋은글 (73)
재테크 (1)
이벤트 (4)

Calendar PHP code 달력

웹프로그래밍™/PHP, ASP, JSP, JAVA 2007/02/04 13:38 by 블루비 Total 550 : Today 4 : Yesterday 0

달력 PHP 소스
<style type='text/css'>
#calendar {
	border-collapse:collapse;
	font-size:9pt;
}
#calendar th { border:1px solid #E6E6E6; background:#D2D2D2; }
#calendar td { border:1px solid #E6E6E6; }
#calendar .bgSat { background:#EEF7FF; }
#calendar .bgSun { background:#FFECEC; }

#calendar a:link { text-decoration:none; }
#calendar a:hover { text-decoration:none; }
#calendar a:visited { text-decoration:none; }
#calendar a:active { text-decoration:none; }

</style>
<?
$date = $_GET['date'];

if( eregi("^[0-9]{4}\-[0-9]{2}\-[0-9]{2}$",$date) ){

	$t = explode("-",$date);
	$year =$t[0];
	$month =$t[1];
	$day =$t[2];

}else{

	$year = date("Y");
	$month = date("m");
	$day = date("d");

}

$timestemp = mktime(0,0,0,$month,1,$year);
$start_week = date("w",$timestemp);
$last_day = date("t",$timestemp);

$prev_date = date("Y-m-d",mktime(0,0,0,$month-1,1,$year));
$next_date = date("Y-m-d",mktime(0,0,0,$month+1,1,$year));


echo "<table border='0' cellpadding='5' cellspacing='0' id='calendar'>";
echo "<caption><a href='?date=$prev_date'><</a> $year/$month <a href='?date=$next_date'>></a></caption>";
echo "<tr><th>Sun</th><th>Mon</th><th>Tue</th><th>Wed</th><th>Thu</th><th>Fri</th><th>Sat</th></tr>";
echo "<tr>";
for( $i = 0 ; $i < $start_week ; $i++ )
{
	echo "<td></td>";
}

for( $days = 1 ; $days <= $last_day ; $days++)
{
	$i++;
	$_days = sprintf("%02d",$days);

	$className = "";
	if( $i%7 == 1 ) $className="class='bgSun'";
	if( $i%7 == 0 ) $className="class='bgSat'";

	echo "<td $className>$_days</td>";
	if( $i%7 == 0 ) echo "</tr><tr>\n";
}

while(1)
{
	if( $i%7 == 0 ) break;
	$i++;
	echo "<td></td>";
	if( $i%7 == 0 ){ echo "</tr>"; break;}

}

echo "</table>";

?>
2007/02/04 13:38 2007/02/04 13:38

TRACKBACK :: http://blueb.net/blog/trackback/742

Leave a Comment
[로그인][오픈아이디란?]
1  ... 382 383 384 385 386 387 388 389 390  ... 775 

달력

«   2008/11   »
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30