Re: COUNT(*) Output Question
| From: | Tom Ray [Lists] | Date: | Mon, 02 Aug 2004 20:31:50 +0000 |
| Subject: | Re: COUNT(*) Output Question | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-192499@lists.php.net to get a copy of this message | ||
Thanks John....I didn't think of that....I've been working on this catalog admin interface for to long......my brain is mush.
John W. Holmes wrote:
From: "Tom Ray [Lists]" <lists@blazestudios.com>$count=mysql_query("SELECT sku, COUNT(*) FROM orders GROUP BY sku"); But my question is how do I use PHP to output the COUNT(*) results? When I run the command when I'm logged into mySQL I get the following:I assume you're fetching associative arrays from the result and $r['sku'] works, but you're not sure how to get the COUNT(*) value? Well, $r['COUNT(*)'] would work, but you could also use an alias: SELECT sku, COUNT(*) AS mycount FROM orders GROUP BY sku and then use $r['mycount'] to retrieve the value (after using mysql_fetch_assoc/array, of course). ---John Holmes...