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 set up to automatically display by date added using:
but I don't know how to change this so the user can select how they're ordered.Code:$sql_order = " ORDER BY date DESC";
I've tried:
Code:$sql_order = ' ORDER BY '. $_GET['orderby'] . ' DESC';Code:$result = mysql_query ($sql_select . $sql_from . $sql_where . $sql_order . $sql_limit);but get an error saying:Code:Order by: <a href='?orderby=name'>name</a> <a href='?orderby=email'>email</a>Line 121 is:Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/west/public_html/search.php on line 121
Warning: implode() [function.implode]: Argument to implode must be an array. in /home/west/public_html/search.php on line 121
Warning: mysql_error(): supplied argument is not a valid MySQL-Link resource in /home/west/public_html/search.php on line 128and that is used to display 5 results at a time and line 128 is: the error that's shown if there was a problem with the queryPHP Code:$results = implode(mysql_fetch_assoc(mysql_query ("SELECT COUNT(*) " . $sql_from . $sql_where . $sql_order)));
I'd be grateful if anybody could give me any help with this.PHP Code:echo("<p>Doh! Error performing query: " . mysql_error($result) . "</p>");
Thanks



Reply With Quote
Bookmarks