Re: count from the results
| From: | olinux | Date: | Sat, 09 Feb 2002 23:33:30 +0000 |
| Subject: | Re: count from the results | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-16765@lists.php.net to get a copy of this message | ||
USe the count() function in mysql.
Like this:
$query = "SELECT count(artist) as howmany FROM artist
WHERE artist LIKE
'b%' GROUP BY artist ORDER BY artist
ASC";
$result = mysql_query($query) or die("Select
Failed!");
echo "<h3>Total Number Of Artists In
\"B\": ";
echo mysql_num_rows($result);
echo "<br><br></h3>";
if (mysql_num_rows($result)) {
echo "<table>";
echo "<tr><th>Artists</th>";
while ($qry = mysql_fetch_array($result)){
echo "<tr>";
echo "<td>";
echo "$qry[artist] ($howmany)";
}}?>
olinux
>
> What I would like to know is how do I do a count on
> each result
> returned.e.g. Benny(4) , Bill(10)
>
__________________________________________________
Do You Yahoo!?
Send FREE Valentine eCards with Yahoo! Greetings!
http://greetings.yahoo.com