Help with MYSQL query using PHP to build a blog archive navigation menu

fahd

New Member
I am building a blog archive navigation menu. Currently I run a query to get all the years and months. Then I loop through and run the following query to get all id's and titles of that year/months blog posts:\[code\]SELECT `id`, `title` FROM `news` WHERE YEAR(`date`) = "2010" AND MONTH(`date`) = "03" ORDER BY `date` DESC\[/code\]After that, to count the amount of posts for that month I am running a very similar query:\[code\]SELECT COUNT(*) as `count` FROM `news` WHERE YEAR(`date`) = "2010" AND MONTH(`date`) = "03"\[/code\]The year and month are dynamic of course.Is there any way to avoid having to run two separate queries?Thanks ahead of time!
 
Back
Top