Results 1 to 3 of 3

Thread: Limiting records selected

  1. #1

    Thread Starter
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    Ok, I have an asp page driven by a database.
    It is a page of links and I would like to know how I can make it so that only 20 records go on each page? (dynamically) then the next 20 can be loaded.

    So
    http://www.mylinks.com/links.asp?page=1
    would show the first 20
    http://www.mylinks.com/links.asp?page=2
    the next 20
    and so on and so forth.

    Do u guys understand?

    and Can u help?

  2. #2
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    here's a quick and easy method...

    there is bound to be a better way but I can't be bothered to find it at the moment!

    exiting the while loop when i = stopval would help as well...


    Code:
    <%@ Language=VBScript%>
    <HTML>
    <head>
    	<!-- Prevent the page from being cached -->
    	<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
    	<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    	</head>
    <BODY>  
    <%
    
    dim strSQL
    dim rst
    dim conn
    dim page 
    dim i 
    dim startval
    dim StopVal
    page = request("page")
    if page = "" then
    	page = 0
    end if
    
     startval = page * 10
     StopVal =  startval + 10
     
    	Set conn = Server.CreateObject("ADODB.Connection")
    	conn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=C:\xxx.mdb")
    
    		strSQL = "SELECT zzzzz FROM tbl1 where f1 ='xxxxxx';"
    	
    		Set rst = conn.Execute(strSQL)
    		
    		
    		while not rst.eof
    			i = i + 1
    			if (i > startval) and (i <= stopval) THEN
    				rst("zzzzz") & "<BR>"
    			END IF	
    			rst.movenext
    			
    		wend
    		rst.close
    		set rst = nothing
    		
    	
    conn.Close
    set conn = nothing
    
    %>
    
    </BODY>
    </HTML>
    Mark
    -------------------

  3. #3
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    Check out this thread on the topic..
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

Posting Permissions

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



Click Here to Expand Forum to Full Width