Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I've been working on this for a day or two, and even tried having the tech support from my hosting place help (which they didn't; just sent me to links where I "might" find the answer). I have a MySQL database. What I want to do is read in an entire table (there's only one field in it), sort the results that come from the table in alphabetical order, and then list them on the screen. The only way I've been able to think of doing this would be array_push()'ing them into an array and then sorting the array. Thus far I have not had any luck it getting that to work. Any ideas? Help's appreciated. (Note: I have to do this in PHP).
<><><>Tope<><><>

You can use the "ORDER BY" statement in the MySQL-query like:
SELECT * FROM tablename ORDER BY FirstName
It is much faster to sort the results by MySQL before outputting them to the php-script. But for your table with only 1 record you wouldnt notice a performance boost ;-)

I didnt read your question very well; you do have more records but only one field. Perhaps you do notice any performance differences now...
SELECT * FROM TableName ORDER BY FieldName
good luck...

Thank you so much! That really helped. I've been sitting here going crazy trying to find ways that I might be able to do it. I just tested it though, and worked perfectly. Is there a part of the MySQL manual that lists all the....I guess you'd call them functions, like that? I've been through it before and all that stuff seems to be spread out through the whole thing. It's much easier to have a list of commands and such and be able to go through and see a short description of what they do, and be able to click on them to see more info on them. I know the PHP manual has a thing like that. Anyway, thanks again!
<><><>Tope<><><>

I personally like old-fashioned manuals for these things. My advice would be to buy a good book.
Otherwise you can try to search the web for a list of mysql commands or post in here if you have any more questions ;-)

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |