multi-row count advice needed.

From: Date: Wed, 27 Dec 2000 05:42:38 +0000
Subject: multi-row count advice needed.
Groups: php.general 
Request: Send a blank email to php-general+get-31920@lists.php.net to get a copy of this message
Hi all! I have a bunch of rows and am counting the "number of instances" within each. Here's what I've figured thus far, am looking for tips on "doing it more efficiently" as to lesson workload on server : $result = mysql_query("SELECT foo FROM table"); while($row = mysql_fetch_array($result)) { if ($row['foo'] == 'a') { $count['a']++; } elseif ($row['foo'] == 'b') { $count['b']++; } elseif ($row['foo'] == 'c') { $count['c']++; } else { $count['z']++; } } Created is an array full of row totals, which is desired. Other ways to do this? TIA! __________________________________________________ Do You Yahoo!? Yahoo! Shopping - Thousands of Stores. Millions of Products. http://shopping.yahoo.com/

« previous php.general (#31920) next »