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.

Sort by LastName

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

Sort by State

$result = mysql_query("SELECT * FROM contacts ORDERBY State");
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.