jeffkas Posted January 26, 2011 Share Posted January 26, 2011 I'm needing some direction in how to start this... I have a page with the 50 U.S. states listed. I have a column in my mysql database that holds each state's name called: source There's a few thousands rows in my database, so the state names vary in the record count. How can I query the database and have a little count by each one of my 50 states that shows how many results exist in the db for that state? I know how to query for total rows and show that number... but confused on how I would do it for individual line items. Thanks for any suggestions. Quote Link to comment https://forums.phpfreaks.com/topic/225702-how-to-poll-mysql-for-results-of-all-50-states/ Share on other sites More sharing options...
PFMaBiSmAd Posted January 26, 2011 Share Posted January 26, 2011 SELECT source, COUNT(*) as cnt FROM your_table GROUP BY source Quote Link to comment https://forums.phpfreaks.com/topic/225702-how-to-poll-mysql-for-results-of-all-50-states/#findComment-1165364 Share on other sites More sharing options...
jeffkas Posted January 26, 2011 Author Share Posted January 26, 2011 Thanks for the help. I should have mentioned that I already got the query to work (though slightly different), but I'm trying to figure out how to pull those results to the page now.. and leave my state names in url form, as they currently are. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/225702-how-to-poll-mysql-for-results-of-all-50-states/#findComment-1165369 Share on other sites More sharing options...
BlueSkyIS Posted January 26, 2011 Share Posted January 26, 2011 http://www.freewebmasterhelp.com/tutorials/phpmysql/4 Quote Link to comment https://forums.phpfreaks.com/topic/225702-how-to-poll-mysql-for-results-of-all-50-states/#findComment-1165480 Share on other sites More sharing options...
Maq Posted January 26, 2011 Share Posted January 26, 2011 Thanks for the help. I should have mentioned that I already got the query to work (though slightly different), but I'm trying to figure out how to pull those results to the page now.. and leave my state names in url form, as they currently are. Thanks! Do you have any code so far? If so, please post it. Quote Link to comment https://forums.phpfreaks.com/topic/225702-how-to-poll-mysql-for-results-of-all-50-states/#findComment-1165482 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.