PDA

Click to See Complete Forum and Search --> : Limiting records selected


da_silvy
Nov 13th, 2000, 03:25 AM
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?

Mark Sreeves
Nov 13th, 2000, 05:20 AM
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...



<%@ 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>

monte96
Nov 14th, 2000, 08:39 AM
Check out this thread (http://forums.vb-world.net/showthread.php?threadid=38186) on the topic..