Kalender: Udskriv år (getdate-funktion)
HejEr ved at lave et event/kalender system. Jeg har følgende stykke kode, der fungerer. Eneste problem er at jeg gerne vil have den til at udkrive året, i parantes ud for måneden. Hvorledes gøres det?
Koden:
$category = $_GET['category'];
if (!empty($category)){
$cat_name = translate($category);
$curtime = time();
$sql = "SELECT * FROM events WHERE category='".$category."' AND start >= $curtime ORDER BY start ASC";
$result = mysql_query($sql) or die("Fejl: ".mysql_error());
$events=array();
while($data=mysql_fetch_assoc($result)){
$time = getdate($data['start']);
$events[$time['mon']][$time['mday']][]=$data;
}
?>
<br>
<table width="500" border="1" class="topmenu" align="center">
<tr><td colspan="2" align="center">
<h1><?=$cat_name;?>events</h1>
</td></tr>
<?
foreach($events as $month => $monthevents){
echo '<tr><td align="center" colspan="2"><div class="h2">'.month($month).'</div></td></tr>';
foreach($monthevents as $date => $dateevents){
echo '<tr><td align="center" width="5"><div class=\"form\">'.$date.'</div></td><td>';
foreach($dateevents as $data){
echo '<a href="index.php?action=show&id=';
echo $data['ID']. '" title="'. $data['title'] .'">';
echo $data['title'] . '</a><br>';
}
echo '</td></tr>';
}
}
echo '</table>';
}