Problem i Kalender
Hejhttp://img256.imageshack.us/img256/3126/snapshot1vit.th.png
Har et problem med at en eller to måneder om året sker denne fejl.
http://img8.imageshack.us/img8/9260/snapshot2o.png
dette er koden:
echo '<script language="JavaScript">
<!--
function win1(url) {
window.open(url,"Calendar","menubar=no,width=460,height=360,toolbar=no");
}
//-->
</script>
';
$monthNames = Array("Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec");
if (!isset($_POST["month"])) $_POST["month"] = date("n");
if (!isset($_POST["year"])) $_POST["year"] = date("Y");
$cMonth = $_POST["month"];
$cYear = $_POST["year"];
$prev_year = $cYear;
$next_year = $cYear;
$prev_month = $cMonth-1;
$next_month = $cMonth+1;
if ($prev_month == 0 )
{
$prev_month = 12;
$prev_year = $cYear - 1;
}
if ($next_month == 13 )
{
$next_month = 1;
$next_year = $cYear + 1;
}
$timestamp = mktime(0,0,0,$cMonth,1,$cYear);
$maxday = date("t",$timestamp);
$thismonth = getdate ($timestamp);
$startday = $thismonth['wday'];
echo '<div id="calendar">
<table width="200px">
<tr>
<td colspan="7" align="center" class="month">
<form action="'.$_SERVER['REQUEST_URI'].'" method="post">
<input type="hidden" name="month" value="'.$prev_month.'">
<input type="hidden" name="year" value="'.$prev_year.'">
<input class="submit" type="submit" value="<<">
</form><strong>
'.$monthNames[$cMonth-1].' '.$cYear.'
</strong> <form action="'.$_SERVER['REQUEST_URI'].'" method="post">
<input type="hidden" name="month" value="'.$next_month.'">
<input type="hidden" name="year" value="'.$next_year.'">
<input class="submit" type="submit" value=">>">
</form>
</td>
</tr>
<tr align="center" class="day">
<td>M</td><td>T</td><td>O</td><td>T</td><td>F</td><td>L</td><td class="sunday">S</td>
</tr>';
$dates = array();
$the_month = $cMonth.'/'.$cYear;
$query = mysql_query("SELECT * FROM Calendar WHERE month='$the_month'");
while($row = mysql_fetch_assoc($query)) //Lav en while der kører alle rækker igennem
{
$dates[$row['date']][$row['id']]['month'] = $row['month'];
$dates[$row['date']][$row['id']]['date'] = $row['date'];
$dates[$row['date']][$row['id']]['time'] = $row['time'];
$dates[$row['date']][$row['id']]['users'] = $row['users'];
$dates[$row['date']][$row['id']]['groups'] = $row['groups'];
$dates[$row['date']][$row['id']]['emne'] = $row['emne'];
$dates[$row['date']][$row['id']]['indhold'] = $row['indhold'];
}
for ($i=0; $i<($maxday+$startday); $i++) {
if(($i % 7) == 1 ){ echo "<tr>\n";}
if($i < $startday){ echo "<td></td>\n";
}else{ echo "<td align='center' valign='middle' height='20px'>";
if(isset($dates[($i - $startday + 1)]))
{
echo "<a href=\"java script:win1('calendar.php?date=".($i - $startday + 1)."&month=".$the_month."')\" onMouseOver=\"self.status='Open A Window'; return true;\">".($i - $startday + 1)."</a>";
}else{
echo ($i - $startday + 1);
}
echo "</td>\n";}
if(($i % 7) == 7 ) echo "</tr>\n";
}
echo '</table>
</div>';
håber der er nogen der kan se problemet