Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 236
  • Last Modified:

Sorting Searc Results via Column Headings

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,
1 Solution
Marcus BointonCommented:
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";
$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.

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now