Assuming roll numbers may not be consecutive in the database.
When you submit with your re-query include the current rollno and a flag to mark prev or next in the querystring
such as
Code:
with response
.write "<a href="
.write chr(34)
.write "/pagename.asp?roll="
.write RollNo
.write "&dir=prev"
.write chr(34)
.write ">Prev</a>"
.write " | "
.write "<a href="
.write chr(34)
.write "/pagename.asp?roll="
.write RollNo
.write "&dir=next"
.write chr(34)
.write ">Next</a>"
end with
BTW the chr(34)s are so that a correct quote mark (") is in the link rather the more common single quote.
then your DB calls would be
Code:
dir = lcase(request.querystring("dir"))
rollno = cint(request.querystring("roll"))
dim i
' conn code and declarations left out
objRS.CursorLocation = adUseClient
' need the above line so that objRS.recordcount doesn't return as -1
strSQL = "SELECT rollno_col as rollno FROM table WHERE criteria ;"
objRS.Open strSQL, objConn, adOpenStatic, adLockReadOnly, adCmdText
for i = 0 to objRS.recordcount -1
if rollno <> cint(objRS.fields("rollno") then
objRS.movenext
else
if dir = "prev" then
objRS.moveprevious
exit for
elseif dir = "next" then
objRS.movenext
exit for
else
exit for
end if
next
rollno = objRS.fields("rollno")
' get the current rollno record
objRS.close
strSQL = "SELECT fieldlist FROM table WHERE rollno_col = rollno ;"
objRS.Open strSQL, objConn, adOpenStatic, adLockReadOnly, adCmdText
objRS now contains the next or previous record
' process the rest of the page
the above code NOT tested just typed in
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
Last edited by chrishirst; 12-27-2006 at 09:44 AM..
Reason: hit submit instead of preview
|