Cat Calendar
Calendar class
This is my simple class for make calendar with linked days that have events in.
< ?php
// set get value passed
$y = (!empty($_GET['y'])) ? $_GET['y'] : '';
$m = (!empty($_GET['m'])) ? $_GET['m'] : '';
$d = (!empty($_GET['d'])) ? $_GET['d'] : '';
// Set url
$url = 'http://www.example.com/archive/';
// Start calendar class sometime need to put EN_en@euro, <a href="mailto:it_IT@euro">it_IT@euro
$calendar = new Cat_Calendar($url, $y, $m, $d);
// Take range date for sql 'date_start' is the database field for date
$sqlCondiction = $calendar->get_db_range('date_start');
$sql = " SELECT date_start".
" FROM news WHERE".
$sqlCondiction.
" AND [ .......... ]";
// Group condiction for have onli one record for date
$sql.= ' GROUP BY date_start ORDER BY date_start DESC';
// Default linked days
$days = array();
// Make query example
if ($res = mysql_query($sql)) {
while($month_info = mysql_fetch_object($res)) {
// Prepare data
$db_days_tmp = explode('-', $month_info->date_start);
// Put in $days array all the query month day
array_push($days, $db_days_tmp[2]);
}
}
// Print returned calendar
echo $calendar->get_calendar($days);
?>

Size: 5.57 KB
Hits : 31
Hits : 31
No Comments »
RSS feed for comments on this post. TrackBack URL
