#native_company# #native_desc#
#native_cta#

Easy Calendar Applications Page 4

By Mark Musone
on July 30, 2000

Following is the complete file, index.php3:

<html><head><title>Calendar</title></head><body><center>

<?php

$montharray=array("","January","February","March","April","May","June","July","August","September","October","November","December");

$current_date=getdate();

if(empty($month)) {

    
$month=$current_date["mon"];

}

if(empty(
$year)) {

    
$year=$current_date["year"];

}

$stream=mcal_open("{/mstore}","musone","hi");

$days=mcal_days_in_month($month,mcal_is_leap_year($year));

$startday=mcal_day_of_week($year,$month,1);

$events=mcal_list_events($stream,$year,$month,1,$year,$month,$days);

for($x=0;$x<count($events);$x++) {

    
$event=mcal_fetch_event($stream,$events[$x]);

    
$start=$event->start;

    
$date_array[$start->mday]=$date_array[$start->mday] . "<br>$event->title";

}

?>



<a href="<?php echo $PHP_SELF?>?month=<?php echo $month-1?>">&lt;</a>

<b><?php echo $montharray[$month] - $year?></b>

<a href="<?php echo $PHP_SELF?>?month=<?php echo $month+1?>">&gt;</a>

<table border=1>

<tr><th>Sun</th><th>Mon</th><th>Tue</th><th>Web</th><th>Thu</th><th>Fri</th><th>Sat</th></tr>

<?php

    
for($i=0;$i<$startday;$i++) {

        echo 
"<td></td>";

    }

    
$dayofweek=$startday;

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

        if ((
$dayofweek == 0) && ($dayofweek !=0)) {

            
printf("</tr>n<tr>");

        }

        echo 
"<td height=100 width=100>";

        echo 
"<A href="addevent.php3?month=$month&year=$year&day=$i">$i";

        echo 
"</a>";

        if (
$date_array[$i]) {

            echo 
"<A href="viewevent.php3?month=$month&year=$year&day=$i">";

            echo 
"$date_array[$i]</a>";

        }

        echo 
"</td>";

        
$dayofweek++;

    }

?>

</tr></table>

</center></body></html>