How to Echo a Distinct Count in PHP?
I have a Mysql that returns a count of items we have in stock
select count(distinct style) from bottles
I want to echo that value out to my website. I tried.
<?php
#///////////////////////////////////
#// Show Amount of Bottles
#///////////////////////////////////
$distinct = mysql_query("select count(distinct style) from bottles", $con);
$num_rows = count($distinct);
echo "$num_rows Bottles In Stock";
?> as of <?php print date('l F jS, Y', time()-86400);
But its only showing me the value of 1? Can someone point me in the right
direction?
Also if I would like to have one statement echo multiple rows how can i do
this?
Item Name | Style | Location
So I would like to echo on our site:
As of today we have 400 bottles of beer in stock X different styles from Y
locations?
Thanks in advance for any help. I just started teaching myself php and
mysql about a month ago.
Ryan
No comments:
Post a Comment