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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with reverse sort...

Status
Not open for further replies.

garfield11

IS-IT--Management
Jul 4, 2002
44
SG
Hi all,

Can anyone pls help me with this:

I got this codes "orderby" whereby when user clicks User Name (header) it will order by user name ASC.

Title: View Users

User Name (header) <-- when click, oderby
ABC
DEF
GH


Eh how can i reverse sort, means i clicks once, orderby ASC, click again, orderby DESC...

<%
String orderby= request.getParameter(&quot;orderby&quot;);

PreparedStatement stmt = conn.prepareStatement(&quot;Select * from users, department, userGroup where users.deptID = department.deptID and users.userGroupID = userGroup.userGroupID order by ?&quot;);
stmt.setString(1, orderby);
ResultSet rs=stmt.executeQuery();
%>

<a href=&quot;viewUser.jsp?orderby=userName&quot;>User Name</a>

Thanks.
 
Well you have to track the &quot;state&quot; of the sort order yes? The two most common methods used to track state is to use the Session object or to use a hidden form variable. Pick one and there is your solution.

-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top