본문 바로가기

PHP

심플 & 허접한 달력.

  <!-- 달력 시작 -->
                                                                                                                                                        <table cellpadding=0 cellspacing=1 bgcolor="aaaaaa">
                                                                                                                                                                <tr>
                                                                                                                                                                        <td bgcolor="888888" align=center height=30><font color=white><b>일</b></font></td>
                                                                                                                                                                        <td bgcolor="888888" align=center><font color=white><b>월</b></font></td>
                                                                                                                                                                        <td bgcolor="888888" align=center><font color=white><b>화</b></font></td>
                                                                                                                                                                        <td bgcolor="888888" align=center><font color=white><b>수</b></font></td>
                                                                                                                                                                        <td bgcolor="888888" align=center><font color=white><b>목</b></font></td>
                                                                                                                                                                        <td bgcolor="888888" align=center><font color=white><b>금</b></font></td>
                                                                                                                                                                        <td bgcolor="888888" align=center><font color=white><b>토</b></font></td>
                                                                                                                                                                </tr>
                                                                                                                                                                <tr>
                                                                                                                                                        <?
                                                                                                                                                        $thisMonth = date('Y-m');
                                                                                                                                                        $thisDayEnd = date('j',strtotime("next month -1 day",strtotime($thisMonth."-01")));

                                                                                                                                                        for($i=1;$i<50;$i++) {

                                                                                                                                                                // 1일 이전의 공백 처리
                                                                                                                                                                for(!$y && $y=0;$y<date('w',strtotime($thisMonth."-01"));$y++) {
                                                                                                                                                                        echo "<td bgcolor='eeeeee'></td>";
                                                                                                                                                                        $i++;
                                                                                                                                                                }

                                                                                                                                                                $printDay =$i-$y;
                                                                                                                                                                
                                                                                                                                                                echo "<td bgcolor='ffffff' height=30 style='padding:2px'><input type='checkbox' name='eatType1Date[]'>".$printDay."</td>";
                                                                                                                                                                if($i % 7 ==0) echo "</tr><tr>";


                                                                                                                                                                // 마지막날 이후의 공백처리
                                                                                                                                                                if($printDay == $thisDayEnd) {
                                                                                                                                                                        for($y=0;$y<(7-($i % 7));$y++) {
                                                                                                                                                                                echo "<td bgcolor='eeeeee'></td>";
                                                                                                                                                                        }                
                                                                                                                                                                        break;
                                                                                                                                                                }

                                                                                                                                                        }
                                                                                                                                                        ?>
                                                                                                                                                                </tr>
                                                                                                                                                        </table>
                                                                                                                                                        <!-- 달력 끝 -->

'PHP' 카테고리의 다른 글

csv 파일 읽기.  (0) 2009.05.20
배열 검색.  (0) 2009.05.20
심플 & 허접한 달력.  (0) 2009.05.20
php 버전별 변수처리  (0) 2009.05.20
아이디 4~15 자 영문 숫자 정규식  (0) 2009.05.20
변수의 문자타입을 출력한다.  (0) 2009.05.20