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 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