<?php
?>
<html>
<head><title>Agenda</title></head>
<body>
<?php
function generate_calendar($year, $month, $day_func = NULL, $day_heading_length = 3)
{
$first_of_month = mktime (0,0,0, $month, 1, $year);
static $day_headings = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
$maxdays = date('t', $first_of_month); #number of days in the month
$date_info = getdate($first_of_month); #get info about the first day of the month
$month = $date_info['mon'];
$year = $date_info['year'];
$calendar = "<table class=\"calendar\" width=\"100%\">\n";
$calendar .= "<tr bgcolor=\"#999999\" class=\"news_title\"><th colspan=\"7\" class=\"month\">$date_info[month], $year</th></tr>\n";
$calendar .= '<tr>';
$weekday = $date_info['wday']; #weekday (zero based) of the first day of the month
$day = 1; #starting day of the month
#take care of the first "empty" days of the month
if($weekday > 0){$calendar .= "<td colspan=\"$weekday\"> </td>";}
include('db.php');
$q = "select date from news";
$buff = mysql_query($q, $linkID);
while ($bline = mysql_fetch_assoc($buff))
{
list($real_date, $junk) = explode(' ', $bline['date']);
$b_days[$real_date]++;
}
#print the days of the month
while ($day <= $maxdays)
{
if($weekday == 7)#start a new week
{
$calendar .= "</tr>\n<tr>";
$weekday = 0;
}
$linkDate = mktime (0,0,0, $month, $day, $year);
if("$month $day $year"==date('m d Y'))
{
$class='today';
}
else
{
$d = date('m/d/Y', $linkDate);
if($b_days[$d])
{
$class = 'post';
}
else
{
$class = 'empty';
}
}
$link = "dates.php?date=$linkDate";
$calendar .= "<td class=\"$class\"> <a class=\"hd\" href=\"$link\">$day</a></td>\n";
$day++;
$weekday++;
}
if($weekday != 7)
{
$calendar .= '<td colspan="' . (7 - $weekday) . '"> </td>';
}
return $calendar . "</tr>\n</table>\n";
}
generate_calendar(date('Y'), date('m'), $day_func = NULL, $day_heading_length = 3)
?>
</body>
</html>
<?php
?>