OK I am really getting confused over here. I did this before but with the contract i signed I couldn't keep the source. I don't remember how I did this either. Someone on here helped me and it was a while back. Here is my code:

<?php
include("connection.inc");
$sql = "SELECT DISTINCT city FROM clients ORDER BY city";
$result = mysql_query($sql);
if (mysql_num_rows($result) < 1) {
print("<b><i>I am sorry there are no matches for that state.</b></i>");
}else{
while ($row = mysql_fetch_array($result)) {
printf("<option value='%s'>%s</option>",$row['city'],$row['city']);
}
}
?>

I have a field that is named cat. Now the deal is that they put in their state and it uses the above code to tell all the cities we have currently for that state. Now I want it to tell me how many cats we have filled under that city.

Example:
Columbus has 4 category's filled
Galena has 6 category's filled
Lancaster has 2 category's filled

I want it to say just:
Columbus (4)
Galena (6)
Lancaster (2)

How can I get the totals? I know how to get the city names... now how do I get the totals? I would appreicate ANY help in this. I don't care if its the smallest thing. Anything will be great!

Chad

    $sql = "SELECT city,count(*) FROM clients group by city ORDER BY city"; 
    

      YOU ROCK! I didn't even think about that whatsoever. Thank you soo much! I really do appreciate it.

        Hey how do you make it order the numbers? I tried an ORDER BY count(*) ... that didnt work. I tried ORDER BY ASC, and DESC neither worked. Can you help me one more time? Thank you!

        Chad

          $sql = "SELECT city,count(*) as numerus FROM clients group by city ORDER BY numerus desc"; 
          

            It isn't working... any other ideas?

            Chad

              ?
              it works well
              maybe some wrong in your code.

                Write a Reply...