unplugged_web Posted June 30, 2008 Share Posted June 30, 2008 I want to have an order by date, name, email etc on a site ,but I don't even know where to start. When somebody goes to the results page I want them to be able to click on say name and then the results are displayed in order of names.At the moment it's se tup to automatically display by date added using: $sql_order = " ORDER BY date DESC"; but I don't know how to change this so the user can select how they're ordered.I'd be grateful if anybody could give me any pointersThanks Link to comment Share on other sites More sharing options...
unplugged_web Posted June 30, 2008 Author Share Posted June 30, 2008 I want to have an order by date, name, email etc on a site ,but I don't even know where to start. When somebody goes to the results page I want them to be able to click on say name and then the results are displayed in order of names.At the moment it's se tup to automatically display by date added using:$sql_order = " ORDER BY date DESC"; but I don't know how to change this so the user can select how they're ordered.I'd be grateful if anybody could give me any pointersThanks I've tried:$sql_order = " ORDER BY '. $_GET['orderby'] . ' DESC"; $result = mysql_query ($sql_select . $sql_from . $sql_where . $sql_order . $sql_limit); Order by: <a href='?orderby=name'>name</a> <a href='?orderby=email'>email</a> but get an error saying: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/west/public_html/search.php on line 74line 74 is:$sql_order = " ORDER BY '. $_GET['orderby'] . ' DESC"; Link to comment Share on other sites More sharing options...
xjx424 Posted June 30, 2008 Share Posted June 30, 2008 I found this to be very helpful if you want to use java. There's a lot of good info on the page.http://www.kryogenix.org/code/browser/sorttable/ Link to comment Share on other sites More sharing options...
unplugged_web Posted June 30, 2008 Author Share Posted June 30, 2008 I found this to be very helpful if you want to use java. There's a lot of good info on the page.http://www.kryogenix.org/code/browser/sorttable/ Thanks, to be honest though I don't know much about Java at all, but will bookmark the page for future reference. Link to comment Share on other sites More sharing options...
xjx424 Posted June 30, 2008 Share Posted June 30, 2008 I bought this when I first started, helped me out a lot. It won't teach you much but is a quick fix for only $30http://www.tom-muck.com/extensions/help/SortRepeatRegion/ Link to comment Share on other sites More sharing options...
unplugged_web Posted June 30, 2008 Author Share Posted June 30, 2008 I bought this when I first started, helped me out a lot. It won't teach you much but is a quick fix for only $30http://www.tom-muck.com/extensions/help/SortRepeatRegion/ It's worth considering and will use it when I get really stuck, but I want to learn how to do it as well.Cheers Link to comment Share on other sites More sharing options...
Synook Posted July 1, 2008 Share Posted July 1, 2008 I've tried:...but get an error saying:...line 74 is:...You've mixed double and single quotes. Try$sql_order = " ORDER BY ". mysql_real_escape_string($_GET['orderby']) . " DESC"; Link to comment Share on other sites More sharing options...
unplugged_web Posted July 1, 2008 Author Share Posted July 1, 2008 You've mixed double and single quotes. Try$sql_order = " ORDER BY ". mysql_real_escape_string($_GET['orderby']) . " DESC"; Thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.