View Single Post
Old 03-08-2008, 01:55 PM   #3 (permalink)
marxx
The Contributor
 
marxx's Avatar
 
Join Date: Sep 2007
Location: Finland
Posts: 45
Thanks: 3
marxx is on a distinguished road
Default

Hi Alan and thanks 4 replying.
Yes I'm fetching these from database (sorry for not metion that ;))

Amm.. What if I don't know which results will be multiple at the time I'm coding this?

Or then I didn't quite understand your examples?
Well let's bake one example this way.

I have news-script where is several posts for each month.
I want to create archive links for each those months, automaticly ofcourse..

I would do it something like this:
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"));

print(
"<li><a href=\"/news/".$year."/".$month."/\">".$datetime."</a></li>\n");

Okey, works but if I have 7 news for march then I have 7 March 2007 links over there.. Now, those I must put as one.

Maybe your example Alan works but I have now clue how I should do it?

Thanks for all help! =)
Send a message via MSN to marxx
marxx is offline  
Reply With Quote