Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

re-ordering a recordset by clicking column title 1

Status
Not open for further replies.

eljacobs

Programmer
Oct 13, 2003
47
GB
Hi

I'd like to allow my site visitors to re-order the results of a recordset by clicking various options such as 'region', 'price' etc.

How would I go about doing this? Would I write something into the sql and add a url parameter?

Thanks in advance

Elliot
 
>>I write something into the sql and add a url parameter?

in the sql - Order by clause
url parameter - guess so...

Known is handfull, Unknown is worldfull
 
Yeah just make your column headers into links with the "sort by" column in the QueryString.

I'm imaginging something like this:
Code:
<%
'... other ASP stuff in here ...

sSQL = "Select * From MyTable "
IF (Len(Request.QueryString("sortby")) > 0) THEN
  sSQL = sSQL & "Order By " & Request.QueryString("sortby")
END IF

'... other ASP stuff in here ...
%>

<!-- other HTML stuff here ... -->

<tr>
  <td>
    <a href="page.asp?sortby=Col1">Column 1</a>
  </td>
  <td>
    <a href="page.asp?sortby=Col2">Column 2</a>
  </td>
  <td>
    <a href="page.asp?sortby=Col3">Column 3</a>
  </td>
</tr>

<!-- other HTML stuff here ... -->
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top