Alpha sorting with PHP & MySQL
|
Original Message
|
Name: Tope
Date: April 19, 2004 at 13:01:37 Pacific
Subject: Alpha sorting with PHP & MySQL OS: WinXP CPU/Ram: 2.53gHZ/512RAM
|
Comment: 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<><><>
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: Khalid
Date: April 19, 2004 at 22:05:59 Pacific
|
Reply: (edit)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 ;-)
Report Offensive Follow Up For Removal
|
|
Response Number 2
|
Name: Khalid
Date: April 19, 2004 at 22:08:00 Pacific
|
Reply: (edit)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...
Report Offensive Follow Up For Removal
|
|
Response Number 3
|
Name: Tope
Date: April 20, 2004 at 11:36:19 Pacific
|
Reply: (edit)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<><><>
Report Offensive Follow Up For Removal
|
|
Response Number 4
|
Name: Khalid
Date: April 20, 2004 at 12:55:37 Pacific
|
Reply: (edit)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 ;-)
Report Offensive Follow Up For Removal
|
Use following form to reply to current message: