View Single Post
  #1 (permalink)  
Old 2008-03-22, 12:29 AM
BATMan_Phln BATMan_Phln is offline
Junior Member
 
Join Date: Mar 2008
Posts: 0
BATMan_Phln is on a distinguished road
Default Sorting records by user preference

I'm a novice at this but I can understand SOME of it so go easy on me.

I have a page that displays record from a database. Some fields are...
Name
Church
Title
State
etc.

I want to put a drop down at the top of the page so the user can sort the records by any of those fields. I had another page set up that would accept a $_GET and show records by category. (A friend wrote the code, not me)

mysql_select_db($db_name);
$query="SELECT * FROM members WHERE category ='" . mysql_escape_string ($_GET[category]) . "' ORDER BY company";
$result=mysql_query($query) or die (mysql_error());

Instead of getting the records just by a field I want it to show all of the record but use the ORDER BY and sort them as stated above. Something like ORDER BY ($_GET[user chosen value]) I would guess. Is this possible?

Thanks,
BATMan
Reply With Quote