Simple question
2 posts by 2 authors in: Forums > CMS Builder
Last Post: January 15, 2010 (RSS)
Hello,
I have a section editor for news.
each news are define with a list option (SPORTS, POLITICS etc)
I want to display live the total number of SPORTS news for exemple.
How to do that?
I have a section editor for news.
each news are define with a list option (SPORTS, POLITICS etc)
I want to display live the total number of SPORTS news for exemple.
How to do that?
Re: [willbegood] Simple question
By Chris - January 15, 2010
Hi willbegood,
You can do that with SQL, or use a little helper function called mysql_select_count_from():
The code above makes some assumptions (in red) about your table and field names. You may need to change these depending on how you've configured your sections.
I hope this helps. Please let me know if you have any questions. :)
You can do that with SQL, or use a little helper function called mysql_select_count_from():
<?php
$tableName = "news";
$whereClause = "category = 'SPORTS'";
$count = mysql_select_count_from($tableName, $whereClause);
echo $count;
?>
The code above makes some assumptions (in red) about your table and field names. You may need to change these depending on how you've configured your sections.
I hope this helps. Please let me know if you have any questions. :)
All the best,
Chris
Chris