showing record count

8 posts by 4 authors in: Forums > CMS Builder
Last Post: January 20, 2012   (RSS)

By (Deleted User) - February 9, 2011

Hi Guys

Is it possible to display a record count on the front-end of my site? i.e.

I want to display how many article or events are added, i.e. "showing 1-6 of 10".

Just so users know how many articles or events are on the site.

regards
Shawn

Re: [smesa] showing record count

By gkornbluth - February 9, 2011

Hi Shawn,

Here's a short recipe from my CMSB Cookbook http://www.thecmsbcookbook.com that should get you started.

WANT TO SHOW A RECORD COUNT ON YOUR WEB PAGE

You can use this to see the total number of records displayed:

<?php echo $your_table_nameMetaData['totalRecords']; ?>

There are a few other variables that can be used besides “totalRecords”. You can list them all with this code:

<xmp><?php print_r($your_table_nameMetaData); ?></xmp>

Hope that works for you,

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] showing record count

By (Deleted User) - February 9, 2011

Works like a charm Jerry. You're a legend!

Thanks very much!

Re: [smesa] showing record count

By s2smedia - January 18, 2012

is there a way to show record count for records that are tagged a certain category.

for example, Im building a small blog and have categories listed down the side (tags). I have a tags section in the CMs where i create tag categories.

In my blog postings, there is a field where I select what tag/categories the post falls under.

Re: [s2smedia] showing record count

By Jason - January 19, 2012

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/

Re: [Jason] showing record count

By s2smedia - January 20, 2012

hmm getting error:
Notice: Undefined variable: tags in /hermes/bosweb26c/b2559/ipw.s2smedia/public_html/test/Shoutfeed/index.php on line 237 ( Notice: Undefined variable: tags in /hermes/bosweb26c/b2559/ipw.s2smedia/public_html/test/Shoutfeed/index.php on line 237 0)


here is my code:

<?php foreach ($newsRecords as $record): ?>
<div style="margin:8px 0px 4px 0px; font-weight:normal"><a href = "<?php echo $tags['_link'];?>">
<?php echo $tags['title'];?> (<?php echo mysql_count('news', "tag = '".$tags['num']."'");?>)
</a> </div>
<?php endforeach ?>


Here is my set up:

category field in my blog is named: "tag"
name of my blog is "news"

not sure what you mean by the option value.

Re: [s2smedia] showing record count

By Jason - January 20, 2012

Hi,

I think the error your getting is because you are using the variable $tags instead of $record.

In your news section, what type of field is "tag"? How is it set up?

Let me know,
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/