PDA

View Full Version : How to advance one month at a time?


deck2deck
11-28-2005, 10:32 AM
Hello all! I've successfully set up this calendar and am very pleased with the way it looks and operates!!

I'm using the 3-month display, but when the user clicks on the forward or back arrows, it advances to the next set of 3 months.

I'm sure there must be an easy way to advance the calendar one month at a time (i.e. now it's showing Oct-Nov-Dec, would like to advance to show Nov-Dec-Jan, then Dec-Jan-Feb, etc.). I've looked and looked and read & re-read the directions but cannot find. :tounge_sm

In case it's out there in plain sight, would someone direct me? Thanks!!!!!:)

Brian
11-28-2005, 10:45 AM
The multi-calendar generator is designed to advance as many months as is being displayed.

You can make it advance only 1 month, but it will require writing your own navigation routine to construct the next and previous buttons (by adding or subtracting 1 from the $mo variable).

Here is a short, quick way to do this:

<?php
$prevMo = $mo-1;
$prevYr = $yr;
if ($prevMo=0) {$prevMo=12; $prevYr--;}

$nextMo = $mo+1;
$nextYr = $yr;
if ($nextMo=13) {$nextMo=1; $nextYr++;}
?>

Then add your own links like this:

<a href='YourFileName.php?mo=$prevMo&$yr=prevYr'>Previous</a>
<a href='YourFileName.php?mo=$nextMo&$yr=nextYr'>Next</a>


You'll probably want to format them differently and align then with the calendars.