The ads stay in the database for 40 days and then they are deleted using a cron script. However, they're only displayed for 30 days. The extra 10 days are to give the owner time to renew the ad whereby it'll be displayed for another 30 days. This part I have no trouble with because I have this in the query:
Expand|Select|Wrap|Line Numbers
- FROM ads WHERE cat_name='$cat_name' &&
- submitted > SUBDATE(NOW(), INTERVAL 30 DAY)
Expand|Select|Wrap|Line Numbers
- $query = "SELECT c.cat_id, c.cat_name, COUNT(d.cat_name)
- as theCount FROM class_categories AS c LEFT OUTER JOIN ads AS
- d ON c.cat_name = d.cat_name GROUP BY c.cat_name";
Expand|Select|Wrap|Line Numbers
- $query = "SELECT c.cat_id, c.cat_name, COUNT(d.cat_name)
- as theCount FROM class_categories AS c LEFT OUTER JOIN ads AS
- d ON c.cat_name = d.cat_name WHERE cat_name='$cat_name' &&
- submitted > SUBDATE(NOW(), INTERVAL 30 DAY)
- GROUP BY c.cat_name";
Any idea how I can get it to display the number of ads (that are within the 30 day display time limit) that each category has?
Thanks
David