Re: [Ginslinger] Category records
Hi,
There are a couple of ways of doing this. Probably the easiest would be to use the function mysql_select_count_from(). This function returns the number of records from a table that meet a given WHERE clause.
Please note that the example below is making a number of assumptions:
1) Your list of categories is in a variable called $categoryRecords.
2)You're storing your listings in a section called "products"
3) Your products section is using a field called "category" to store it's category value
4) The category field used the "num" from the category section as it's value.
Given these assumptions, your code could look like this:
<?php foreach ($categoryRecords as $category): ?>
<?php
$where = "category = '".$category['num']."'";
$recordCount = mysql_select_count_from('products', $where);
?>
<?php endforeach ?>
You then have a variable called $recordCount that you can output where ever you like, like this:
<?php echo $recordCount;?>
Hope this helps get you started.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/