$messages=mysql_query("select * from messages where type='announcement' order by sendtime limit 1",$mydb);
$message=mysql_fetch_assoc($messages);
$news=mysql_query("select * from news order by newsdate limit 1",$mydb);
$new=mysql_fetch_assoc($news);
if (($new[newsdate]!="") && ($new[newsdate]<$message[sendtime]))
{
$startdate=$new[newsdate];
}
elseif ($message[sendtime]!="")
{
$startdate=$message[sendtime];
}
else
{
$startdate=$new[newsdate];
}
$enddate=time();
if ($startdate)
{
$workdate=$enddate;
$changes[$changesection].='<a class="menu-item" href="index.php?action=archives&showdate='.date("MY",$workdate).'">'.date("M Y",$workdate).'</a>';
while (date("M Y",$workdate)!=date("M Y",$startdate))
{
$tempdate=$workdate;
while (date("M Y",$tempdate)==date("M Y",$workdate))
{
$tempdate-=86400;
}
$workdate=$tempdate;
$changes[$changesection].='<a class="menu-item" href="index.php?action=archives&showdate='.date("MY",$workdate).'">'.date("M Y",$workdate).'</a>';
}
}