Order MySQL results by first letter

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
thunderbox
Forum Newbie
Posts: 13
Joined: Wed Mar 07, 2007 4:06 pm

Order MySQL results by first letter

Post by thunderbox »

hey im writing a user system, and in the admin panel i need the option to ONLY show usernames selected by the Admin (from a dropdown box)
i have the Letter being submitted by a $_POST command, but I'm not sure how to order the results based on that $_POST submission

thanx for your help
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

To only return results starting with a specified letter:

Code: Select all

SELECT * FROM `table` WHERE `column` LIKE 'a%' ORDER BY `column`;
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Yea go with aaron, I missed the mysql part.
thunderbox
Forum Newbie
Posts: 13
Joined: Wed Mar 07, 2007 4:06 pm

Post by thunderbox »

thanx guys.... i was completely stumped on the sort() command.. i didn't know what to do with it
Post Reply