Page 1 of 1

Looping through months

Posted: Fri Nov 14, 2008 3:30 pm
by fluidbyte
I'm creating an article listing system, and just like every blog/news site out there I would like to create an archive by month/year.

I've got the starting month (##) and starting year (####) (and of course I know the current month (##) and current year(####)), I just can't figure out how to loop out the months in between. I know someone out there has to know how to do this...

Re: Looping through months

Posted: Fri Nov 14, 2008 5:01 pm
by josh

Code: Select all

 
for( $offset = 1; $offset <= 12; $offset++ )
{
  $current_month++;
  if( $current_month == 13 )
  {
     $current_month=1;
     $curent_year++;
  }
}
 
something like that?

Re: Looping through months

Posted: Fri Nov 14, 2008 5:20 pm
by VladSun
Where does the data come from? From DB?
What do you mean by "create an archive" exaclty?