Support forum login

©2006-2008 IAAI Software

Contact Us

Number of all products

Submitted by Peter on Sat, 2006-07-29 16:21.

Hello,

how can i display the number off all products in my database?

I did make it with following code, but it did not work...

$sql = "Select count(*) from products";
$result = mysql_query($sql);
$rec = mysql_fetch_row($result);

Please help me :)

Thanks a lot, Peter

Submitted by dmorison on Sat, 2006-07-29 17:04.

Hi Peter,

Using the database library in the Price Tapestry distribution, here's a script to show you the total number of products (put this script in your Price Tapestry directory):

numProducts.php:

<?php
  
require("config.php");
  require(
"includes/database.php");
  
$sql "SELECT count(*) as numProducts FROM `".$config_databaseTablePrefix."products`";
  
database_querySelect($sql,$rows);
  
$numProducts $rows[0]["numProducts"];
  print 
"<p>Total products in database: ".$numProducts."</p>";
?>

Your code is not far off - I think you would have just need to print the value of $rec["count(*)"] to get the product count.

Cheers!
David.

Submitted by Peter on Sat, 2006-07-29 18:30.

Thanks for your fast answer.

It works perfekt...

Peter