웹마스터 팁

cal.JPG
<!--
        // 달력
        // 작성자 : 최문혁
        // 작성일 : 2005-9-5
-->
<style>
        a:link{color:white;text-decoration:none;}
        a:visited{color:white;text-decoration:none;}
        a:active{color:white;text-decoration:none;}
        a:hover{color:#ff0000;text-decoration:underline}
</style>

<?php
        
        //$curM = 2;
        //처음 시작할때.. 그러니까 월을 선택하지 않았을때...
        if ($curM =="")
        {
                //오늘을 기준으로 연도와 달을 찾는다.
                $tmpDate = getdate();
                $curY = $tmpDate[year];
                $curM = $tmpDate[mon];
                $curD = $tmpDate[mday];
        }
        
        //유닉스 타임스탬프 형식으로 현재달의 1일을 찾아 둔다.
        $preM = $curM - 1;
        $nextM = $curM + 1;
        $preY = $curY;
        $nextY = $curY;
        
        if ($curM==1)
        {
                $preM = 12;
                $preY = $curY - 1;
        }
        elseif($curM==12)
        {
                $nextM = 1;
                $nextY = $curY + 1;
        }
                
        $preDate = mktime(0,0,0,$preM, 1,$preY);
        $curDate = mktime(0,0,0,$curM, 1,$curY);
        $nextDate = mktime(0,0,0,$nextM, 1,$nextY);

        $preMaxday = date(t,$preDate);
        $curMaxday = date(t,$curDate);
        $nextMaxday = date(t,$nextDate);

        $preFw = date(w,$preDate);        //요일을 숫자로 나타낸것(0=일요일,1=월요일)
        $curFw = date(w,$curDate);        //요일을 숫자로 나타낸것(0=일요일,1=월요일)
        $nextFw = date(w,$nextDate);        //요일을 숫자로 나타낸것(0=일요일,1=월요일)

        $preJu = floor(($preMaxday+$preFw)/7)+1 ;         //
        $curJu =floor(($curMaxday+$curFw)/7)+2 ;         //
        $nextJu = floor(($nextMaxday+$nextFw)/7)+1 ;         //
        $yoil = array('','SUN','MON','TUE','WEN','THR','FRI','SAT');
        $month = array('','January','February','May','April','March','June'+ ','July','August','September','October','November','December');
        
        //양옆 미니달력 만들기 함수
        function mk_mCal($y,$m,$ju,$fw,$maxday)
        {
                GLOBAL $preM, $preY, $preJu, $preFw, $preMaxday, $nextJu, $nextFw, $nextMaxday, $yoil, $month;
                $cur=0;
                echo "<center><font face=굴림 size=2 color='#3399FF'>".$y."-".$m."</font></center><table  cellspacing=2 cellpadding=0 height=150>";
                        for($row = 0;$row<=$ju;$row++)
                        {
                                echo "<tr align=center>";
                                for($col = 1;$col<=7;$col++)
                                {
                                        echo "<td><font face=굴림 size=2 color='#3399FF'>";
                                        if ($row==0)
                                        {
                                                echo "<u>".$yoil[$col]."</u>";
                                        }
                                        else
                                        {
                                                $cur++;
                                                if (($cur <= $fw) || ($cur-$fw>$maxday)==true)
                                                {
                                                        echo " ";
                                                }
                                                else
                                                {
                                                        if ($cur-$preFw<10)
                                                        {
                                                                echo "0";
                                                                echo $cur-$fw;
                                                        }
                                                        else
                                                        {
                                                                echo $cur-$fw;
                                                        }//헉
                                                }//헉
                                        }//헉
                                }//헉
                        }//헉
                echo "</table>";
        }

        //좌측,우측에 작은 달력.
        echo "<table width=100% ><tr><td>";
        //여기 전달 달력
        mk_mCal($preY,$preM,$preJu, $preFw, $preMaxday);
        echo "</td><td width=70% align=center>";
        //여기 현재 달
        echo "<b>".$curY."   <font size=10>".$curM."</font>  ".$month[$curM]."</font></b>";
        echo "</td><td>";
        //여기 다음달 달력
        mk_mCal($nextY,$nextM,$nextJu,$nextFw,$nextMaxday);
        echo "</td></tr></table>";


        //메인테이블 시작
        $cur = 0;
        echo "<table border=0 width=100% height=70% cellspacing=1 cellpadding=0 bgcolor='#6699CC'>";
        for($row = 0;$row<=$curJu;$row++)
        {
                //row에 대한 첫번째 루프라면 현재달과 전달 다음달을 표시하기위한 칸
                if ($row==0)
                {
                        echo "<tr height=10><td colspan=3><font size=2 color=white> <a href=$PHP_SELF?curY=$preY&curM=$preM&curD=$curD>이전달</a>  ";
                        echo "<a href=$PHP_SELF>오늘</a>  <a href=$PHP_SELF?curY=$nextY&curM=$nextM&curD=$curD>다음달</a></font></td></tr>";
                }
                else
                {                        
                        echo "<tr bgcolor='#FFFFFF'>";         //한줄 그린다.
                        
                        for($col = 1;$col<=7;$col++)        //한주가 7일이니깐 7번 돈다.
                        {                                
                                if($row==1)         //요일을 넣기위한 칸^^
                                {
                                        echo "<td height=30 width=14.2857% align=center><font face='arial black'>";
                                        echo "<font color=black>";
                                        if ($col==1) echo "<font color=red>";
                                        if ($col==7) echo "<font color=blue>";
                                        echo "<h4>$yoil[$col]</h></font><br>";
                                }else{                                        
                                        $cur++;        //공백까지 포함해서 1씩 증가하는데, 일자를 출력할땐 공백의 갯수 뺀다.
                                        if (($cur<=$curFw) || ($cur > ($curMaxday+$curFw)) == true)
                                        {                                                
                                                echo "<td valign=top> ";        
                                        }else{
                                                
                                                if (($cur-$curFw)==$curD)//오늘일자 하이라이트.
                                                {
                                                        echo "<td valign=top bgcolor=#6699CC>";        //한칸 그리고
                                                }else{
                                                        echo "<td valign=top>";        //한칸 그리고
                                                }
                                                
                                                //일자 표시 부분... 각각 테이블이 들어간다. 디자인을 위해서..
                                                echo "<table border=0 height=10 width=100% height=100% bgcolor=EEEEEE cellspacing=0 cellpadding=0><tr><td align=right>";
                                                echo "<font color=black>";
                                                if ($col==1) echo "<font color=red>";
                                                if ($col==7) echo "<font color=blue>";
                                                echo $cur-$curFw;                                        
                                                echo "</font> </td></tr></table>";
                                        }
                                }
                                echo "</td>";
                        }
                        echo "</tr>";
                }
        }

        echo "</table>";

?>
제목 글쓴이 날짜
[PHP 동영상강좌] 9. form태그를 이용한 값의 전달 [15] 서기 2005.11.22
[PHP 동영상강좌] 8. Get방식의 전달과 테이블, 스타일태그의 사용 [13] 서기 2005.11.22
[PHP 동영상강좌] 7. Get방식을 이용한 변수의 전달 [12] 서기 2005.11.22
[PHP 동영상강좌] 6. Hello PHP [14] 서기 2005.11.22
[PHP 동영상강좌] 5. 웹서버/웹브라우져/PHP란 무엇인가 [12] 서기 2005.11.17
[PHP 동영상강좌] 4. 스타일 시트 [17] 서기 2005.11.17
[PHP 동영상강좌] 3. 테이블 태그의 심화 [10] 서기 2005.11.17
[PHP 동영상강좌] 2. 하이퍼링크, 테이블태그의 사용방법 [15] 서기 2005.11.17
[PHP 동영상강좌] 1. HTML이란 무엇인가! [22] 서기 2005.11.17
주민등록번호 진위확인 [5] file 엔시™ 2005.11.08
예전에 책원고로 만들었던것인데 필요한분 사용하세요 [7] file 유창화 2005.10.22
이쁜 달력소스입니다. [2] file 최문혁 2005.09.05
자기계정에서 file()가 잘안될때.... [5] 이진환님 2005.08.18
일년치 달력을 한꺼번에 보자!!! [4] 未淚 2005.08.07
효율적인 경로 지정하기 [9] 대류 2005.07.27
대용량 파일 업로드 컴포넌트 [4] file OTLNO 2005.06.15
트랙백 기능 구현하기. 태규 2005.06.12
나만의 미니홈 만들기 ㅡ 메모장 소스 예뜨락 2005.06.09
mysql 테이블 스키마 보는법. [2] 최문혁 2005.05.14
나만의 미니홈 만들기 ㅡ 메모장 디자인 (html 소스) [4] 예뜨락 2005.05.12