Witam!
Problem tkwi w tym że skrypt wysypuje mi się przy pobieraniu miesiąca i roku. Będę wdzięczny za wszelkie porady/uwagi.

<html>
<head>

 <meta http-equiv="Content-type" content="text/html; charset=windows-1250" />

<head>

<title>Kalendarz</title>

</head>
<body>
<?php
if (is_numeric($_GET['month']))
{
$month=$_GET['month'];
}
else $month = date('n');

if(is_numeric($_GET['year']))
{
$year=$_GET['year'];
}
else $year = date('Y');

$first_of_this_month = mktime(0,0,0,$month,$year);
$first_day_in_week_number = date('w',$first_of_this_month);
$days_in_this_month = date("t",$first_of_month);
$today = mktime(0,0,0,date('n'),date('Y'));

$day_names=array(
'Niedziela',
'Poniedziałek',
'Wtorek',
'środa',
'Czwartek',
'Piątek',
'Sobota'
);

$month_names=array(
'Styczeń',
'Luty',
'Marzec',
'Kwiecień',
'Maj',
'Czerwiec',
'Lipiec',
'Sierpie«',
'Wrzesie«',
'Październik',
'Listopad',
'Grudzień'
);

$first_of_previous_month = mktime(0, 0, 0, $month - 1, 1, $year);
$first_of_next_month = mktime(0, 0, 0, $month + 1, 1, $year);
$this_month_name=$month_names[date('n',$first_of_this_month)];
$previous_month_name=$month_names[date('n',$first_of_previous_month)];
$next_month_name=$month_names[date('n',$first_of_next_month)];

if ($month > 1)
{
$previous_month = $month- 1;
$previous_year = $year;
}
else
{ $previous_month=12;
$previous_year = $year-1;
}
if ($month > 11)
{
$next_month = 1;
$next_year = $year+1;
}
else
{
$next_month=$month+1;
$next_year = $year;
}
?>
<table>
<tr>
<th colspan="2">
<a href="kalendarz.php?month=<?=$previous_month ?>&amp;year=<?=$previous_year ?>">
&lt;&lt;<?=$previous_month_name ?>
</a></th>
<th colspan="3"><?= $this_month_name.' '.$year ?></th>
<th colspan="2">
<a href="kalendarz.php?month=<?=$next_month ?>&amp;year=<?=$next_year ?>">
<?=$next_month_name ?>&gt;&gt;
</a></th>
</tr>
<tr>
<?php
foreach ($day_names as $day_name)
{
echo '<th>'.$day_name.'</th>';
}
?>
</tr>
<?php
$tab_before=array();
$tab_after=array();
$days = array();
if ($first_day_in_week_number > 0)
for ($i=0;$i<$first_day_in_week_number;$i++)
$tab_before[] ='&nbsp;';
$last_of_this_month = mktime(0,0,0,$month,$days_in_this_month,$year);

$last_day_in_week_number=date('w',$last_of_this_month);
if ($last_day_in_week_number<6)
for ($i=$last_day_in_week_number+1;$i<=6;$i++)
$tab_after[] ='&nbsp;';

for ($i=1;$i<=$days_in_this_month;$i++)
$days[]=$i;
$all =(isset($tab_before))?array_merge($tab_before,$days):$days;
$all =(isset($tab_after))?array_merge($all,$tab_after):$all;
$end_of_loop=count($all);
$i=0;
while ($i<$end_of_loop) {
echo '<tr>';
foreach ($day_names as $day_name)
{
echo '<td class="'.$class.'">'.$all[$i].'</td>';
$i++;
}
echo '</tr>';
}
?>
</table>


</body>
</html>