PDA

View Full Version : Displaying data with PHP?


Ocean11
08-08-2005, 05:47 PM
I am trying to work with a database that has already been created. I am having trouble adding new entries to my DB, every time I ad a new entry (using PHP myadmin) When the new entries are displayed they dont show up in alphabetical order by organization name instead I think they are being sorted by id.

My question is, is there anyway to sort my database and display the data by the organization name field rather than by the assigned IDs? An example can be seen at http://www.bluefront.org/selectorganizations.php if you select colorado on the next page you will find that "a jeff tester" is out of order.

Thank you all so much in advance for any help you might be able to give. :vday2:

Winters
08-08-2005, 06:25 PM
I think you can do something like this...

SELECT fields FROM table ORDER BY field_name

but I dunno for sure that's off the top of my head. Not much of a guru.

gymshoe
08-10-2005, 01:55 AM
Winters is correct, you need to change the query to include the "ORDER BY column-name" ....

You can also designate how you want it sorted. I think by default the ORDER BY will do it alphabetically or numerically ..but if you want it in reverse or something, then you need to add in:

"ORDER BY column-name ASC" for ascending order or
"ORDER BY column-name DESC" for descending order.

so your query will look something like...

SELECT * FROM database ORDER BY column-name ASC