How to show links to cats/dates only if there are articles in that date

2 posts by 2 authors in: Forums > CMS Builder
Last Post: May 21, 2012   (RSS)

Re: [kblm] How to show links to cats/dates only if there are articles in that date

By robin - May 21, 2012

Hey Kevin,

Here is some sample sql to get you started, something like this should just pull the months/years that have articles. You can then use a foreach loop on the $monthYears variable and use the data as needed.


$monthYearQuery = "
SELECT YEAR(datetime) as articleYear, MONTH(datetime) as articleMonth
FROM " . $TABLE_PREFIX . "every_field_multi
ORDER BY articleYear, articleMonth";

$monthYears = mysql_fetch($monthYearQuery);


Hope that helps. You can use a similar query to just pull subcategories that have articles.

Robin
Robin
Programmer
interactivetools.com