Record Count

8 posts by 3 authors in: Forums > CMS Builder
Last Post: December 27, 2008   (RSS)

By rcrofoot - February 19, 2008

[font "Arial"]Dave- [font "Arial"]One last question...Other than setting up a ForEach loop and incrementing a counter variable, is there a way to return the record count (number of records returned) in a List Viewer page??? [font "Arial"]I checked the documentation, but couldn't find anything... [font "Arial"]Rick [font "Arial"] [font "Arial"] Hi Rick,

You can use this to see the total number of records:
<?php echo $listDetails['totalRecords']; ?>

There's a few other variables available as well, you can list them all with this code:
<xmp><?php print_r($listDetails); ?></xmp>

However, if you want the number of record _displayed_ on the page and not the total count then you'd need to use a counter. Most of the time the number of records displayed on a page would be the same as the per page value (except when you're on the last page).

Hope that makes sense. If there's something in particular that you are trying to do and you're not sure how feel free to let me know and I can help you figure it out. (Post in the forum if you can since that helps other people too).

Hope that helps!

Re: [rcrofoot] Record Count

By Dave - February 20, 2008

Thanks for posting that! Helpful for anyone else who wants to do the same.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Record Count

By jposwald - November 25, 2008

It's not working with new versions of CMS Builder.

How can I show total records listed in List Page?

Thank you, Juan.

Re: [jposwald] Record Count

By Dave - November 25, 2008

It should still work. What's it showing for you?

Note that the variable might be different in your viewer file, not $listDetails but something else.
Dave Edis - Senior Developer
interactivetools.com

Re: [jposwald] Record Count

By Dave - December 3, 2008

Hi Juan,

You need to make sure the variable names are the same as the ones used in your viewer page.

Try $featured_propertiesMetaData instead of $listDetails

Let me know if that works for you.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Record Count

By rcrofoot - December 26, 2008

Hi Dave-

Back to the record count question from earlier this year...I need to get the total number of records returned from a CMS query...

As a test, when I tried: <xmp><?php print_r($certificationsRecords); ?></xmp>[/#ff0000], I got a printout of every field and its data for every record in every table...[/#000000]('[/#ff0000]certifications' is my table name)...[/#ff0000]

When I tried: <?php echo $certificationsRecords['totalRecords']; ?>[/#ff0000],[/#ff0000] I got this error: Notice: Undefined index: totalRecords in /var/www/vhosts/ebscerts.com/httpdocs/show_product_list_test.php on line 43[/#ff0000]

Short of putting a counter in one of the foreach loops, is there a way to just retrieve the total number of records returned from a CMS query???

Thanks, and hope you and your family had a wonderful Christmas!

Rick

Re: [rcrofoot] Record Count

By Dave - December 27, 2008

Hi Rick,

Do you want the total records shown on the page (eg: 10) or the total records matched (could be much higher such as 43).

There should be a second variable returned by getRecords() that has info such as that. Try this:
<?php echo $certificationsMetaData['totalRecords']; ?>

Or have a look through the values available using this debug code and use one of them:
<xmp><?php print_r($certificationsMetaData); ?></xmp>

Hope that helps! Let me know how it goes.
Dave Edis - Senior Developer
interactivetools.com