Web Hosting Talk







View Full Version : Alphabetize MySQL data


iamdave
07-02-2005, 10:38 PM
When I display something on a PHP page that is taken from a MYSQL database, how is it possible to alphabetize the data. The data in each row is separated by a column. ANY HELP? THANKS!!!;)

laserlight
07-03-2005, 12:07 AM
You probably have to ORDER BY some column.

rackgeek
07-03-2005, 01:17 AM
Hello:

Here's a good tutorial i would recommend you look through:

http://www.freewebmasterhelp.com/tutorials/phpmysql/6

Hope it helps.

Thanks!

iamdave
07-03-2005, 07:42 AM
The thing is, the data is one field, like TABLE 1 row1.col2 the data that is displayed needs to be alphabetized.

Vulture
07-03-2005, 07:47 AM
Could you; query the database, get the results in an array using mysql_fetch_array or similar (you'd want to use the MYSQL_ASSOC type, otherwise you'd get numerics aswell), then use the sort() function to sort into alphabetical order?

I've not tried this...but I can't see why it wouldn't work.

laserlight
07-03-2005, 08:45 AM
Originally posted by iamdave
The thing is, the data is one field, like TABLE 1 row1.col2 the data that is displayed needs to be alphabetized.
Then just order by that field.

iamdave
07-05-2005, 04:35 AM
Originally posted by Vulture
Could you; query the database, get the results in an array using mysql_fetch_array or similar (you'd want to use the MYSQL_ASSOC type, otherwise you'd get numerics aswell), then use the sort() function to sort into alphabetical order?

I've not tried this...but I can't see why it wouldn't work. That would probably be the best solution.

laserlight
07-05-2005, 07:00 AM
That would probably be the best solution.
It wouldnt - shifting the sorting logic to the database is better since this isnt a special case.