Hi - I'm building a site with several 'one-liners'. These are added using a simple PHP5 form, stored in a MySQL 5 database. Each row has an 'id' (auto_increment), 'title', 'description', 'status' (1 or 0) and 'date_added' (MySQL datetime).
I want to display them grouped by Month and Year, like so:
<dl>
<dt>August 2009</dt>
<dd><strong>title 1</strong> - description 1</dd>
<dd><strong>title 2</strong> - description 2</dd>
<dd><strong>title 3</strong> - description 3</dd>
etc...
</dl>
<dl>
<dt>July 2009</dt>
<dd><strong>title 1</strong> - description 1</dd>
<dd><strong>title 2</strong> - description 2</dd>
<dd><strong>title 3</strong> - description 3</dd>
etc...
</dl>
I found a MySQL snippet which ostensibly groups rows by month, however the query only returns a couple of results, rather than the full table:
SELECT `title`, `description`, `date_added`
FROM one_liners WHERE `status`=1 GROUP BY MONTH(date_added)
How would I go about grouping them, and then looping to display as above?
Any help would be greatly appreciated.
Thanks!