Jump to content

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


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.

 

:)

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.