954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

sort on field names; refresh page?

I only started last week with php mysql(be nice)

I have a MySQL db where a user can enter contact info, usually stuff:
FirstName
LastName
Address
City
State
Zip

I return this info to a php page which shows all info in db.

$result = mysql_query("SELECT * FROM contacts");

I would like to make some sort fields for the page. Sort by LastName or Sort by State.

I know how to write the sql for the query for the db, what I am unsure of is how to use it on the php page and get the page re-displayed when the label is clicked?

hope thats clear. thank you for your time.

vree
Newbie Poster
2 posts since Sep 2004
Reputation Points: 10
Solved Threads: 0
 

Sort by LastName
[PHP]$result = mysql_query("SELECT * FROM contacts ORDERBY LastName");[/PHP]

Sort by State
[PHP]$result = mysql_query("SELECT * FROM contacts ORDERBY State");[/PHP]

PoA
Posting Whiz in Training
237 posts since Jul 2004
Reputation Points: 26
Solved Threads: 9
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You