i am working on a calendar and i have it set up so that you can cyclye throuhg the months and i want it to change the year as well like if its january of 2007 and you hit prev i want it to become december of 2006.

i have the calendar working completely with the next and prev links working to a point it changes the month ok and i managed to get it to chnage the year when you go from december to january, however for some reason it will not change the year when i go from january to december, even though i used the exact same method to accomplish both.

this is the code i used to accomplish the month switch
PHP Code:
if(empty($_GET['month'])){
    
$today1 getdate(); 
        
$month=$today1['mon'];
}else{
$month=$_GET['month'];}
            
if(empty(
$_GET['year'])){
    
$today2 getdate(); 
    
$year=$today2['year'];
}else{
$year=$_GET['year'];}
            
if(
$month==0){
    
$month=12;
    
$year--;
}
            
if(
$month==13){
    
$month=1;
    
$year++;
}
            
fWriteCalendar(fGetEvents(),$month,$year); 
this is the part of the calendar write function that handles it

PHP Code:
function fWriteCalendar($vResults,$vMonth,$vYear){

$today  getdate();
$temp1 getdate(mktime(0,0,0,$vMonth,1,$vYear));
$temp2 getdate(mktime(0,0,0,$vMonth+1,0,$vYear));
$introoffset $temp1['wday'];
$closeoffset $temp2['wday'];
$days=$temp2['mday'];
$month=$temp1['month'];
$prevmonth  $vMonth-1;
$nextmonth  $vMonth+1;
 
$vCalendar'
<a href="calendar.php?month='
.$prevmonth.'&year='.$year.'"><<</a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Calender of Events for '
.$month.'-'.$vYear.
'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="calendar.php?month='
.$nextmonth.'&year='.$year.'">>></a>; 
if anyone can help me figure out why the year will not decrease from january to december it would help alot.