Showing number of listings next to link for predetermined search

12 posts by 3 authors in: Forums > CMS Builder
Last Post: April 10, 2013   (RSS)

By CommonSenseDesign - April 9, 2013

Thanks for the reply, Greg.

The Catalogue Category (field name: category) is added via a drop down menu in CMSB. The various options in this field are added in a text field of a separate section/table of the cms, called Catalogue Categories (table name: catalogue_categories).

As the category is selected from a drop down menu, the user can only choose one option.

Is that the information you wanted?

Please can you tell me how the mysql_count function should be added, and where it should go?

By gregThomas - April 10, 2013

Hi Nigel,

What is the name of the table that you want to count items from? Something like this should work, you would have to add it around line 153 of storecategories.php:

<ul>
  <?php foreach ($catalogue_categoriesRecords as $record): ?>
    <?php $counter = mysql_count('table_of_items_you_want_to_count', "category = ".$record['num']);
    <li>
      <?php $count = 0; ?><a href="<?php echo $record['_link'] ?>"><?php echo htmlencode($record['title']) ?>
      &nbsp;&raquo;</a>&nbsp;(<?php echo $counter; ?>&nbsp;items)
    </li>
  <?php endforeach ?>
</ul>

So you'll need to change the name of the table that is used in the mysql_count function to the name of the table that has the category field. The second variable of the mysql_count function is the where string you want to use. In this case we want to count items which have a category value of the current category.

Let me know if you have any questions.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com