<?
include_once("./_common.php");
?>
<style>
.day_month	{ text-align:center; font:bold 11px dotum;color:#000 }
.day_week1	{ text-align:center; font:normal 11px dotum; color:#d30300; border-top:1px solid #dddddd; border-bottom:1px solid #dddddd; height:25px; }
.day_week2	{ text-align:center; font:normal 11px dotum; border-top:1px solid #dddddd; border-bottom:1px solid #dddddd; height:25px; }
.day_day1	{ text-align:center; font:normal 11px dotum; color:#d30300; height:20px; }
.day_day2	{ text-align:center; font:normal 11px dotum; height:20px; }
</style>
<?
if(!$year){
$year = date("Y");
}
 
if(!$month){
$month = date("m");
}
 
if(!$day){
$day = date("j");
}
 
$next_year = date("Y",strtotime($year."-".$month."-".$day."+1 year"));
$prev_year = date("Y",strtotime($year."-".$month."-".$day."-1 year"));
 
$prev_year2 = date("Y", mktime (0,0,0,$month-1, $day, $year));
$prev_mon2 = date("n", mktime (0,0,0,$month-1, $day, $year));
 
$next_year2 = date("Y", mktime (0,0,0,$month+1, $day, $year));
$next_mon2 = date("n", mktime (0,0,0,$month+1, $day, $year));
 

$time = strtotime($year.'-'.$month.'-01'); 
list($tday, $sweek) = explode('-', date('t-w', $time)); // 총 일수, 시작요일 
$tweek = ceil(($tday + $sweek) / 7); // 총 주차 
$lweek = date('w', strtotime($year.'-'.$month.'-'.$tday)); // 마지막요일 
?> 

		<table width="140" height="30" border="0" cellspacing="0" cellpadding="0" align="center">
			<tr>
				<td align="center"><a href="javascript:chg_calendar('<?=$prev_year2?>','<?=$prev_mon2?>')"><img src="../images/day_prev.gif"></a></td>
				<td align="center" class="day_month"><?=$year?><?=$month?></td>
				<td align="center">
				<a href="javascript:chg_calendar('<?=$next_year2?>','<?=$next_mon2?>')"><img src="../images/day_next.gif"></a>
				
				</td>
			</tr>
		</table>

	<table width="205" border="0" cellspacing="0" cellpadding="0" align="center">
			<tr>
			   <td class="day_week1"></td>
			   <td class="day_week2"></td>
			   <td class="day_week2"></td>
			   <td class="day_week2"></td>
			   <td class="day_week2"></td>
			   <td class="day_week2"></td>
			   <td class="day_week2"></td>
			</tr>
<? for ($n=1,$i=0; $i<$tweek; $i++) { ?> 
<tr> 


<? for ($k=0; $k<7; $k++) { ?> 



<?
if ($n==date("d") && $month == date("m") && $year == date("Y") ) //오늘
{
	$t_st = ";background:#ca9569;color:#fff";
} else {
	$t_st = "";
}


$sd = mktime("00","00","00",$month,$n,$year);

$s_st = "";
$onc = "";
if($its[sDate] <= $sd && $its[eDate] >= $sd ) {
	$td = mktime("00","00","00",date("m"),date("d"),date("Y"));

}

?>
 
<td align='center' id="<?=$sd?>"<?=$k == 0 ? "class='dd day_day1'" : "class='dd day_day2'" ?> style='<?=$t_st?><?=$s_st?>' <?=$onc?> > 

<? if (!(($i == 0 && $k < $sweek) || ($i == $tweek-1 && $k > $lweek))) { ?> 

<?=$n?> 

<?
$n++
?>
 

<? } //if?> 


<br><!--td채우기-->
 
</td> 

<? } //for?> 


</tr> 
<? } //for?> 
</table> 

<script>

function chg_calendar(y,m) {
	$.ajax({
		type:"post",
		url:"calendar.php",
		data:"year="+y+"&month="+m,
		success:function(dt) {
			$("#calgooksu").html(dt);
		}
	});
}
</script>

'PROGRAM > PHP' 카테고리의 다른 글

$_SERVER 함수정리  (0) 2013.09.12
array 및 strpos 이용하여 페이지 별 active  (0) 2013.09.06
리스트에서 파일출력  (0) 2013.07.09
변수값 넘기고 받기  (0) 2013.06.27
그누보드 여분필드 쪼개기  (0) 2013.05.24