tags:

views:

39

answers:

2

basically I have some SQL and I want the user to be able to select the ordering in the "order by" section with an HTML element. Are there any out-of-the-box solutions?

edit: it's more like order by country,status,... or order by status,country,...

A: 

You can use a select to choose which category to search through, and then a radio button to choose ascending or descending order.

Dropdown

<select name='search'>
    <option>Name</option>
    <option>Telephone</option>
    <option>Address</option>
</select>

Radio Buttons

<input type='radio' name='order' value='asc' /> Ascending
<input type='radio' name='order' value='desc' /> Descending​​​​​​​​​​​​

Not knowing what server-side technology you're using somewhat limits the question, but basically get the value from the select, and then order depending on the radio button.

Robert
A: 

if u display your sql results in a list view u can change display order by clicking on the header of your displayed fields.

EDIT: have a look at this. (hold down shift key and click on headers)

rahim asgari