View Single Post
Old 03-08-2008, 02:12 PM   #4 (permalink)
Alan @ CIT
Member of the Month
The Frequenter
Member of the Month Top Contributor 
 
Alan @ CIT's Avatar
 
Join Date: Apr 2005
Location: South UK
Posts: 483
Thanks: 51
Alan @ CIT is on a distinguished road
Default

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
Send a message via MSN to Alan @ CIT
Alan @ CIT is offline  
Reply With Quote
The Following User Says Thank You to Alan @ CIT For This Useful Post:
marxx (03-08-2008)