It took me a while to figure out how to write my own MySQL query with the correct PHP syntax that Zen Cart likes. I thought I’d share it with you.

For example. Lets say you want to find out how many reviews were made for a particular product and display the number on the product description page. You would use the following and place it on your /includes/templates/YOUR-TEMPLATE/templates/tpl_product_info_display.php page. Of course, modify the style to match your page.

<?php
$this_sku_sql_for_reviews = "SELECT COUNT(products_id) as products_id, status FROM reviews where products_id = '" . $_GET&#91;'products_id'&#93; . "'";
$this_sku_reviews = $db->Execute($this_sku_sql_for_reviews);        
    if($this_sku_reviews->fields['status'] == 1) {
        echo "<p align="center" style="font-size:10px;margin-bottom:5px;">". $this_sku_reviews->fields['products_id']." reviews</p>";
    }
?>