xProteuSx Posted December 11, 2008 Share Posted December 11, 2008 I have a DB of countries, and I would like to list them alphabetically, and also by letter heading. I know how to list them alphabetically, and I also know how to list just the A's, B's, C's etc. but I only know how to do this using multiple DB queries. Is there any way to do this with a single query? ... A: Afghanistan, Albania, Algeria, Angola, etc etc B: Bahamas, Bahrain, Bangladesh, etc etc C: Cambodia, Cameroon, Canada, etc etc etc ... Quote Link to comment https://forums.phpfreaks.com/topic/136471-alphabetize-and-group-by-first-letter/ Share on other sites More sharing options...
blueman378 Posted December 11, 2008 Share Posted December 11, 2008 could you not query them all at once, then just 'pluck' out the names from the array which start with X letter Quote Link to comment https://forums.phpfreaks.com/topic/136471-alphabetize-and-group-by-first-letter/#findComment-712310 Share on other sites More sharing options...
xProteuSx Posted December 11, 2008 Author Share Posted December 11, 2008 Hmm ... I have a bad habit of avoiding arrays, because I have never used them before. I guess that its time for me to learn. After all, they are SUPER important. I will figure this out tomorrow. Thanks for your suggestion (which is probably 100% right). Quote Link to comment https://forums.phpfreaks.com/topic/136471-alphabetize-and-group-by-first-letter/#findComment-712315 Share on other sites More sharing options...
blueman378 Posted December 11, 2008 Share Posted December 11, 2008 na theres always a better way than what i saiy but thats the best i can see, someone will come in with one line of code or something that will do what you want eventually lol Quote Link to comment https://forums.phpfreaks.com/topic/136471-alphabetize-and-group-by-first-letter/#findComment-712316 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.