Great Calendar Class

I have always needed a calendar class that just works. I found this one that is really easy to use. So this works great if you want to hard code the calendar. I needed to be able to plot a date range and have the dates highlighted. The data is coming from a MySQL database.
     // First thing first, include the class
    require "/path/to/calendar.class.php";    

     // Next go get your dates from your database.  I have "start" and "end" fields.  I have a function that takes care of this
     require "/path/to/your/db/connection.php";

     $sql = mysql_query(" SELECT * FROM dates WHERE id = 'weekTrip' ");
     while ($date = mysql_fetch_object($sql)) {
        $start = strtotime($date->start);
        $end = strtotime($date->end);
        //This next section builds the dynamic starting and end months for the calendar
        $start_date_year = date("Y", $start); 
        $start_date_month = date("m", $start);        
        $end_date_year = date("Y", $end); 
        $end_date_month = date("m", $end);                
                do {
          $range[] = date('Y-m-d', $start);
                  $start = strtotime("+ 1 day", $start);
                while($start <= $end);
         $calendar = new Calendar();
         // This part of the class builds the range of dates.  Normally you build this section like this:
         // $calendar->highlighted_dates = array('2011-02-20','2011-02-21','2011-02-22','2011-02-23','2011-02-24'); 
         $calendar->highlighted_dates = $range;
         $calendar->link_days = false;                                                                                                                                                                                               
         // This line builds the end month if the date range extends beyond the starting month.  (this will only work for date ranges less than one year)
         if ($start_date_month != $end_date_month) {                                                                                    
Post a comment

Real Time Web Analytics ^