Jump to content


Sort and Count Array from MYSql

  • Please log in to reply
1 reply to this topic

#1 dareid5

  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 13 October 2006 - 12:46 PM

I have a db that holds user entries in a poll.  They select their favorite city.  Doing so enters the city and state associated with that state.

I would like to count each ‘vote’ for a city and list by state then show the highest rated cities.

My problem right now is I’m not able to pull the data for the db and create an array that I can use to view it.

Any help would be appreciated.



#2 craygo

  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 13 October 2006 - 12:52 PM

give us your field names so i can tweak the sql, but basically it would be like this

$sql = "SELECT count(city) AS citytotal, state from tablename group by state, city";

Didn't test it but should be it.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users