03-08-2008, 02:12 PM
|
#4 (permalink)
|
|
The Frequenter
Join Date: Apr 2005
Location: South UK
Posts: 483
Thanks: 51
|
In your example above I would move the unique check to the PHP code.
For example, instead of print()'ing your date links, I would add them to an array and then use array_unique() on it to strip out duplicates.
Something like the following (untested) should work:
PHP Code:
$q = mysql_query("SELECT added FROM news ORDER BY added DESC") or die(mysql_error());
while($q1 = mysql_fetch_array($q)) {
$timestamp = $q1['added'];
$datetime = date("F Y" , strtotime("$timestamp"));
$year = date("Y", strtotime("$timestamp"));
$month = date("m", strtotime("$timestamp"));
$dates[] = "<li><a href=\"/news/".$year."/".$month."/\">".$datetime."</a></li>\n";
}
$dates = array_unique($dates);
foreach ($dates as $datelink)
{
echo $datelink;
}
Alan
|
|
|