Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder:
showing record count

 

 


smesa
User

Feb 9, 2011, 4:07 AM

Post #1 of 8 (1428 views)
Shortcut
showing record count Can't Post

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


gkornbluth
Veteran

Feb 9, 2011, 4:58 AM

Post #2 of 8 (1426 views)
Shortcut
Re: [smesa] showing record count [In reply to] Can't Post

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:


Code
<?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:


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!
http://www.thecmsbcookbook.com


smesa
User

Feb 9, 2011, 5:49 AM

Post #3 of 8 (1422 views)
Shortcut
Re: [gkornbluth] showing record count [In reply to] Can't Post

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

Thanks very much!


s2smedia
User

Jan 18, 2012, 8:28 PM

Post #4 of 8 (1279 views)
Shortcut
Re: [smesa] showing record count [In reply to] Can't Post

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.


Jason
Staff / Moderator


Jan 19, 2012, 11:20 AM

Post #5 of 8 (1268 views)
Shortcut
Re: [s2smedia] showing record count [In reply to] Can't Post

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:



Code
<?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 - Programmer 
interactivetools.com

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


s2smedia
User

Jan 20, 2012, 11:16 AM

Post #6 of 8 (1259 views)
Shortcut
Re: [Jason] showing record count [In reply to] Can't Post

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.


Jason
Staff / Moderator


Jan 20, 2012, 11:29 AM

Post #7 of 8 (1258 views)
Shortcut
Re: [s2smedia] showing record count [In reply to] Can't Post

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 - Programmer 
interactivetools.com

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


s2smedia
User

Jan 20, 2012, 11:41 AM

Post #8 of 8 (1255 views)
Shortcut
Re: [Jason] showing record count [In reply to] Can't Post

GOT IT.. Works like a charm!! thx