Jump to content

[SOLVED] How can I create a query/code that categorize a list of months by months?


winterain

Recommended Posts

Hi all,

Ok, so my title might have been a little confusing.

 

I'm writing a simple news list section, and all is done except for the final part which I'm stuck in. Which is a list of Months for the user to select, which will then show the list of articles in that month.

 

My current query is like this :

 

$query_dates = " SELECT DATE_FORMAT( date, '%M %Y' ) AS date_text, DATE_FORMAT( date, '%m') AS month FROM design_news ORDER BY date DESC";

 

Which lists the months of EVERY entry, so I'm getting an output like:

 

November 2008
November 2008
November 2008
October 2008
October 2008
October 2008

 

What I need to achieve is :

 

November 2008
October 2008

 

Regardless of how many entries.

 

Can anyone guide/help me out please?

 

Thank you very much!

 

 

 

Thank you very much!

GROUP BY Month(date) and it worked beautifully.

 

Thanks for the quick reply, because I was about to pull my hairs out trying to study search results which suggested for each looping through arrays.

 

:)

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.