my mysql statement doesnt return correct results
Hi there on my product listing page I want to show how many times a product is displayed in a category.
So I am using the following SQL statement in the rsCatalog
But the bottom 5 records should be displaying 1 (if you look at the screenshot for the catalog table you will see that the bottom 5 records only occur once. Waht could be wrong with my SQL statement.
<?php
$rsProducts = new WA_MySQLi_RS("rsProducts",$ecartdb,0);
$rsProducts->setQuery("SELECT * FROM products");
$rsProducts->execute();?>
<?php
$rsCatalog = new WA_MySQLi_RS("rsCatalog",$ecartdb,1);
$rsCatalog->setQuery("select CatalogProductID, count(*) as assigned FROM catalog GROUP BY CatalogProductID");
$rsCatalog->execute();
?>
here is some of the code for the loop:
<?php if ($rsProducts->TotalRows > 0) { // Show if mysqli recordset not empty ?>
....
<td><?php echo($rsCatalog->getColumnVal("assigned")); ?></td>
....
<?php
$rsProducts->moveNext();
}
$rsProducts->moveFirst(); //return RS to first record
?>
Chris