So i'm creating a simple news system with php mysql.
I am storing the date of each news post as a date field in a mysql database.
I need to be able to query the DB and group the news posts by month and date and display archive links in the sidebar like this
Archive November 2008 December 2008 January 2008
etc.
any help would be appreciated.
Thanks
The word 'group' explains exactly what you need. This sort of thing should do the trick:
SELECT MONTHNAME(dateCoumn) AS month, YEAR (dateCoumn) As year
FROM news
GROUP BY
YEAR (dateCoumn),
MONTHNAME(dateCoumn)
ORDER BY
dateCoumn ASC
Yeah that looks like what I need. Thanks.
How do i then get the monthname and year echoed out on the page?
nevermind. I figured it out. Thanks for you help. Much appreciated.
Sorry, you must be a member to post to a conversation. Either
log in or
sign up
to get involved.