Re: [s2smedia] showing record count
Hi,
No problem. If you are using CMS Builder version 2.08 or higher, the easiest way to do this is with the mysql_count function.
In this example, I'm making several assumptions:
1) the name of your category field in your blog section is called "category"
2) the option value of that field is the num field from your category section
3) the name of your blog section is "blog".
If any of these are incorrect, you'll need to adjust this example, but it should get you started.
What we're going to do is, in our foreach loop that is outputting our categories, just mysql_count to get the number of blog posts that match the category currently being output:
example:
<?php foreach ($blogCategories as $category): ?>
<a href = "<?php echo $category['_link'];?>">
<?php echo $category['title'];?> (<?php echo mysql_count('blog', "category = '".$category['num']."'");?>)
</a>
<?php endforeach ?>
Hope this helps get you started.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/