?
Solved

Sorting Searc Results via Column Headings

Posted on 2005-03-18
2
Medium Priority
?
223 Views
Last Modified: 2008-03-10
Hello Amigos,

I want to be able to stack my search results by clicking on the column heading a-z ; z-a.

I thought DWMX would have it built in to the server behaviors panel as an option but no. I have no idea where to begin.

Thanks Guys,
0
Comment
Question by:plannett
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 25

Accepted Solution

by:
Marcus Bointon earned 250 total points
ID: 13576357
make the column heading into a link which repeats the current query (you should have stored the settings that were used for that in the session so you don't have to pass it all back again), but specifies a different sort order, so you could have:

<th>Name (<a href="?order=za">A-Z</a>)</th>

Then in your script:
if (array_key_exists('order', $_GET) and $_GET['order'] == 'za')
$sql = "SELECT * FROM table ORDER BY name DESC";
else
$sql = "SELECT * FROM table ORDER BY name ASC";

It will obviously need a bit more work to reconstruct your query, but you will be doing that already.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question