Location: PHPKode > scripts > pcCalendar > pccalendar/events_demo.php3
<?
        /* 
                events_demo.php3 - Example of using pcCalendar class as an event calendar
                Copyright (c) 2000, Polaris Computing
                http://www.polaris.ca/
        */

        include( 'pccalendar.php3' );

        class myCalendar extends pcCalendar
        {
                function myCalendar()
                {
                        /* Override the constructor function.  Default is to use long names for the days
                           of the week, but we want a small and cute calendar. */

                        $this->gaWeekTitles[] = "Su";
                        $this->gaWeekTitles[] = "Mo";
                        $this->gaWeekTitles[] = "Tu";
                        $this->gaWeekTitles[] = "We";
                        $this->gaWeekTitles[] = "Th";
                        $this->gaWeekTitles[] = "Fr";
                        $this->gaWeekTitles[] = "Sa";
                }

                function intStartTable()
                {
                        /* define how the table should be presented */

                        echo '<table border=3>';
                }

                function intDisplayWeekTitle( $intWeekDay )
                {
                        /* define how titles of the week are to be displayed */

                        echo '<td><font class="font-family: Arial; font-size: 9pt; color: #000000"><b>';
                        echo $this->gaWeekTitles[ $intWeekDay ];
                        echo '</b></font></td>';
                }

                function intDisplayDay( $intYear, $intMonth, $intDay )
                {
                        /* check database to see if there are any events for today */
                        $query = sprintf( 'SELECT * FROM event WHERE eventdate = "%s-%s-%s"', $intYear, $intMonth,
                                $intDay );
                        $res = mysql_query( $query );

                        /* define how the days of the month are to be displayed */

                        echo '<td';
                        if ( mysql_num_rows( $res ) > 0 )
                                echo ' bgcolor="#FFFF00"';
                        echo '><font class="font-family: Arial; font-size: 8pt; color: #000000">';
                        echo $intDay;
                        echo '</font></td>';
                }
        }

        /* no other functions in the pcCalendar need to be overridden. */

        /* connect to MySQL database */
        mysql_connect( "hostname", "userid", "password" );
        mysql_select_db( "database" );

        /* create new Calendar instance */
        $cal = new myCalendar;

        /* display calendar for current month & year */
        $cal->intShowCalendar();

?>
Return current item: pcCalendar