MYSQL Record Count

5 posts by 2 authors in: Forums > CMS Builder
Last Post: July 15, 2014   (RSS)

By shawn - July 14, 2014

Hi guys,

I have created a checkbox called "Popular" and at the moment its returning the count of all listings checked. However, how do I get a count of listings checked as popular belonging to my multi-list values? i.e.  'where' => "city = 'CT'",

list($listingRecords, $listingMetaData) = getRecords(array(
    'tableName'   => 'listing',
    'where' => "city = 'CT'",
  ));

This is giving me the record count of all listings checked "Popular".

<? echo mysql_select_count_from('listing','popular');?>

I want to know how many listings are checked popular for the City = "CT"...

Any assistance greatly appreciated.

By shawn - July 15, 2014

Hello Claire

Thank you for the reply. Not sure what you mean exactly? It's just a checkbox field type with fieldname "popular". The table name is 'tableName'   => 'listing',

Popular (value): <?php echo $record['popular'] ?>
Popular (text):  <?php echo $record['popular:text'] ?>


I have a muli-list called "city".

 City (value): <?php echo $record['city'] ?>
 City (label): <?php echo $record['city:label'] ?>

So I basically I'm filtering my listings: 'where' => "city = 'CT'", and would like to know which over those listings in "CT"are checked as "Popular".

At the moment I can return a count for all listings checked as popular like this, but only want those 'where' => "city = 'CT'"

<? echo mysql_select_count_from('listing','popular');?>

By claire - July 15, 2014

Hi Shawn

Just wanted to be sure I understand what your setup is like. Try this function instead:

<?php echo mysql_count('listing', 'city = "CT" AND popular = 1'); ?>

This will give you a little more leeway in how you select the records.

--------------------

Claire Ryan
interactivetools.com

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

By shawn - July 15, 2014

Works like a charm! Thank you Claire :)