Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jul 2004
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts

    keeping 'sortorder' on 'Next Page'

    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
    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'
    Code:
    <%
    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
    Code:
    <%
    		' 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
    Web and Business Development from Cornwall - Startbar.co.uk

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,043
    Thanks
    0
    Thanked 251 Times in 247 Posts
    <a href="<%= strURL %>?display=<%= Server.URLEncode(strSearch) %>&page=<%= iPageCurrent + 1 %>&sortby=<%=ordervariable%>&sortorder=<%=sortorder%>" class="linkw2"> Next Page</a>

  • #3
    Regular Coder
    Join Date
    Jul 2004
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks!!
    Web and Business Development from Cornwall - Startbar.co.uk


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •