#! c:/perl/bin/perl.exe use strict; use CGI qw (header); use CGI::Carp qw(fatalsToBrowser); use DBI; use HTML::CalendarMonthSimple; my $myyear=2001; my $mymonth=10; # month to pull data on # # set up database connectivity & retrieve records # the dbi method selectall_arrayref was added in DBI v1.15. # my $dbi=DBI->connect("DBI:mysql:host=myhost:user=nobody") || die ("no dbi",DBI->errstr); $dbi->do ("use mydatabase") || die DBI->errstr; my @items = @{$dbi->selectall_arrayref ( "SELECT title, dayofmonth(date), detail FROM table WHERE month (date) = $mymonth AND year (date) = $myyear order by dayofmonth(date)")}; # # set up the calendar & populate information # my $cal = new HTML::CalendarMonthSimple('year'=>$myyear,'month'=>$mymonth); $cal->width('100%'); $cal->border(2); $cal->header('Monthly data'); $cal->bgcolor('whitesmoke'); # # populate calendar with data # foreach my $row (@items) { $cal->addcontent($$row[1], "$$row[0]
$$row[2]"); } print header; print $cal->as_HTML;