You are here:  » Print total number (info)

Active Forum Topics


Print total number (info)

Submitted by safari45 on Fri, 2021-01-29 13:43 in

Hi Devid,

Hope you are doing well today.

I want to print the total number of products, Brand, categories, merchants

eg:
- 10000 Products
- 950 Brands
- 59 Categories
- 8 Merchants

Submitted by support on Fri, 2021-01-29 15:14

Hello Safari,

Here's the basic code to show the counts where required;

<?php
  
print "<ul>";
  
$sql "SELECT count(DISTINCT(name)) as numProducts FROM `".$config_databaseTablePrefix."products`";
  
database_querySelect($sql,$rows);
  
$numProducts $rows[0]["numProducts"];
  print 
"<li>".$numProducts." Products</li>";
  
$sql "SELECT count(DISTINCT(brand)) as numBrands FROM `".$config_databaseTablePrefix."products`";
  
database_querySelect($sql,$rows);
  
$numBrands $rows[0]["numBrands"];
  print 
"<li>".$numBrands." Brands</li>";
  
$sql "SELECT count(DISTINCT(category)) as numCategories FROM `".$config_databaseTablePrefix."products`";
  
database_querySelect($sql,$rows);
  
$numCategories $rows[0]["numCategories"];
  print 
"<li>".$numCategories." Categories</li>";
  
$sql "SELECT count(DISTINCT(merchant)) as numMerchants FROM `".$config_databaseTablePrefix."products`";
  
database_querySelect($sql,$rows);
  
$numMerchants $rows[0]["numMerchants"];
  print 
"<li>".$numMerchants." Merchants</li>";
  print 
"</ul>";
?>

Cheers,
David.
--
PriceTapestry.com

Submitted by safari45 on Fri, 2021-01-29 17:37

Great thanks