Number of all products
Submitted by Peter on Sat, 2006-07-29 16:21.Price Tapestry
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
Thanks for your fast answer.
It works perfekt...
Peter
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:
<?phprequire("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.