first.. you need to find the number of categories in
the table.. Use a simple MySQL function for that.
Example:

mysql> SELECT `table.categoryfield`, COUNT(*) FROM
`table` GROUP BY `table.categoryfield`;

this will return each category, and how many rows use
this category. Example:

+---------------------+----------------+
| table.categoryfield | table.COUNT(*) |
+---------------------+----------------+
|           Category1 |          14356 |
|           Category2 |             34 |
|           Category3 |            343 |
+---------------------+----------------+

or if you just want the plain number of categories,
use COUNT(*). Example:

SELECT COUNT(DISTINCT table.categoryfield) FROM
`table`;

which returns a single element, the number of unique
categories.

I hope this may help you!

Regards,

Brian Burg
Hudsonville Web Design Team
http://www.hudsonville.k12.mi.us


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to