...

View Full Version : keeping 'sortorder' on 'Next Page'



startbar
07-24-2004, 04:05 PM
hi, i have a little problem. I have links on my site so users can sort the data from the access database by name or town for example. When 10 entries are shown it goes to another page but when the user clicks on the 'Next Page' button is just shows the results from the default 'sort order' and not the one specified by the user!

The sorting code

dim ordervariable, sortorder
ordervariable = "Name" 'default column to sort on
sortorder = "ASC" 'default sortorder

if (len(request.querystring("sortby")) >= 1) then
ordervariable = request.querystring("sortby")
end if
if (len(request.querystring("sortorder")) >= 1) then
sortorder = request.querystring("sortorder")
end if

strSearch = Replace(strSearch, "'", "''")
strSQL = "SELECT Name, Category, County, Date, Summary, URL, Town, ID, Status " _
& "FROM NETWORK " _
& "WHERE Status=1 " _
& "AND (Name LIKE '%" & strSearch & "%' " _
& "OR Category LIKE '%" & strSearch & "%' " _
& "OR Town LIKE '%" & strSearch & "%' " _
& "OR County LIKE '%" & strSearch & "%') " _
& "ORDER BY " & ordervariable & " " & sortorder

an example of the 'users sort choice'

<%
if strSearch = "%" then
response.write "Sort results by: <a href=""network.asp?display=" & strSearch & "25&sortby=Name&sortorder=ASC"" class=""readmore"">Company Name</a>"
else
response.write "Sort results by: <a href=""network.asp?display=" & strSearch & "&sortby=Name&sortorder=ASC"" class=""readmore"">Company Name</a>"
end if
%>

and finally the code for the navigation

<%
' Now we need to show our navigation links:

' Show "previous" and "next" page links which pass the page to
' view our search parameter. You could also use form buttons
' but I find this looks better.
If iPageCurrent > 1 Then
%>


<font class="pcount"><a href="<%= strURL %>?display=<%= Server.URLEncode(strSearch) %>&page=<%= iPageCurrent - 1 %>&sortby=Name&sortorder=ASC" class="linkw2">Previous Page </a>
<%
End If

' You can also show page numbers:
For I = 1 To iPageCount
If I = iPageCurrent Then
%>
<font class="page"><%= I %>
<%
Else
%>
<font class="pcount"><font class="text"><a href="<%= strURL %>?display=<%= Server.URLEncode(strSearch) %>&page=<%= I %>&sortby=Name&sortorder=ASC" class="linkw2"><%= I %></a>
<%
End If
Next 'I

If iPageCurrent < iPageCount Then
%>
<font class="pcount"><a href="<%= strURL %>?display=<%= Server.URLEncode(strSearch) %>&page=<%= iPageCurrent + 1 %>"& ordervariable & " " & sortorder &" class="linkw2"> Next Page</a>
<%
End If
%>
</p>
<%
End If

' Close our recordset and connection and dispose of the objects
rstSearch.Close
Set rstSearch = Nothing
cnnSearch.Close
Set cnnSearch = Nothing
End If
%>


sorry to be boring but any ideas?!!?!?

thanks ppl

glenngv
07-26-2004, 04:30 AM
<a href="<%= strURL %>?display=<%= Server.URLEncode(strSearch) %>&page=<%= iPageCurrent + 1 %>&sortby=<%=ordervariable%>&sortorder=<%=sortorder%>" class="linkw2"> Next Page</a>

startbar
07-26-2004, 10:30 AM
thanks!!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum