I have made my own calendar which is very simple. Here is what works: It will display the current month. I do get the twelve links I want from the current month plus eleven more. What I don’t get is when I select a link a variable or actually two variables are not passed so that the selection of month and year that was made is the new calendar month while the twelvelinks stay the same. This is a snipet of my first protram.
<?php
if (!isset($_GET[‘$month’])) {
$month = isset($_GET[‘month’]) ? intval($_GET[‘month’]) : date(‘m’);
}
if (!isset($_GET[‘$year’])) {
$year = isset($_GET{‘year’}) ? intval($_GET[‘year’]) : date(‘Y’);
}
$month_choice = date(‘m’);
$year_choice = date(‘Y’);
for ($i=1;$i<=12;$i++) {
if ($month_choice > 12) {
$month_choice = 1;
$year_choice+=1;
}
print ‘<li><a class=“pick_month” href=“where_we_are.php?$month=$month_choice&$year=$year_choice”>’ . date(‘M Y’,mktime(0,0,0,$month_choice,1,$year_choice)) . ‘</a></li>’;
$month_choice++;
}
?>
</ul>
</div>
<div id=“cal_grid”>
<?php
print ‘<table class=“calendar”><caption class=“month”>’ . date(‘F Y’,mktime(0,0,0,$month,1,$year)) . ‘</caption>’;
print ‘<tr><th>SUNDAY</th><th>MONDAY</th><th>TUESDAY</th><th>WEDNESDAY</th><th>THURSDAY</th><th>FRIDAY</th><th>SATURDAY</th></tr>’;
$totaldays = date(‘t’,mktime(0,0,0,$month,1,$year));
$offset = date(‘w’,mktime(0,0,0,$month,1,$year));
print ‘<tr>’;
if ($offset > 0) {
for ($i = 0;$i < $offset;$i++) {
print ‘<td></td>’;
}
}
for ($day =1;$day <= $totaldays;$day++) {
print “<td>” . $day . “</td>”;
$offset++;
if ($offset == 7) {
$offset = 0;
if ($day < $totaldays) {
print “</tr>
<tr>”;
}
}
}
if ($offset > 0) {
$offset = 7 - $offset;
}
if ($offset > 0) {
for ($i = 0;$i < $offset;$i++) {
print ‘<td></td>’;
}
}
print ‘</tr></table>’;
?>
</div>