Oct
12
2008

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);
?>
download
Size: 5.57 KB
Hits : 31

Share and Enjoy:
  • Facebook
  • del.icio.us
  • Twitter
  • Google Bookmarks
  • Digg
  • Technorati
  • MySpace
  • Live
  • BlinkList
  • Add to favorites
  • email
  • RSS
  • Mixx
  • Bitacoras.com
  • blogmarks
  • Blogosphere News
  • Blogplay
  • connotea
  • Current
  • Diggita
  • Diigo
  • DZone
  • eKudos
  • Internetmedia
  • LinkedIn
  • MSN Reporter
  • Reddit
  • Scoopeo
  • Segnalo
  • Slashdot
  • Socialogs
  • Sphinn
Written by Davide in: Library,php | Tags: , ,

No Comments »

RSS feed for comments on this post. TrackBack URL

Leave a comment

Theme: TheBuckmaker.com Magazine Style Templates