Re: count from the results

From: Date: Sat, 09 Feb 2002 23:41:13 +0000
Subject: Re: count from the results
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-16766@lists.php.net to get a copy of this message
Hi Barry! you can do it like this for example: $query = "SELECT * FROM artist WHERE artist_name LIKE 'b%' ORDER BY artist ASC"; $count = mysql_query("SELECT COUNT(artist) AS count FROM artist WHERE artist_name LIKE 'b%'",$db); $x = mysql_fetch_array($count); $result = mysql_query($query) or die("Select Failed!"); $number = $x["count"]; echo "<h3>Total Number Of Artists In \"B\":&nbsp;&nbsp;"; echo "$number"; 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]; > }}?> "Barry Rumsey" <webmaster@musicsearch.ath.cx> wrote in message news:php.db-16754@news.php.net... > I have the following code: > $query = "SELECT * FROM artist WHERE artist LIKE 'b%' ORDER BY artist > ASC"; > $result = mysql_query($query) or die("Select Failed!"); > echo "<h3>Total Number Of Artists In \"B\":&nbsp;&nbsp;"; > 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]; > }}?> > > What I would like to know is how do I do a count on each result > returned.e.g. Benny(4) , Bill(10) > >

« previous php.db (#16766) next »