Not a Member Yet,
Click here to Register
How do you like the new design?






ID: 510
Viewed: 2943
Added: Sep 02, 2003
Version: 1.0
Snippet uploaded by: snippet
Written By: Johan
Demo: Sorry, no demo



User Rated at: 3 Stars3 Stars3 Stars
Rate This:

Thank you for your vote. Please wait...

It appears you already voted for this snippet

It appears your vote value was empty

Very handy little script for ASP users that want to break up there queries per page.

Browsers: ALL

<!---Head--->
'// Include the includes

<%

Function pageData()

Dim out, db, Rs, strSql, intID, iPageSize, iPage, bNoRecords, nTotalRecords, iTotalPages

Dim bOnePage, nPageEnd, nPageStart, lCtr, bLastPage, sNextQuery, iCtr, sQuery, sPageQuery, sPrevQuery

iPageSize = 15

If Request.QueryString("Page") <> "" And IsNumeric(Request.QueryString("Page")) Then

iPage = CInt(Request.QueryString("Page"))

Else

iPage = 1

End If

strSql = "SELECT *, Review.ID AS [reviewID] FROM review WHERE Review.Delete<>'Y' ORDER BY Title"
Set db = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("ADODB.Recordset")
db.Open "DSN=futuremovies"

Rs.Open strSql, db, 1, 3

If Not rs.EOF And Not rs.BOF Then
rs.MoveLast
nTotalRecords = rs.RecordCount

iTotalPages = Int(nTotalRecords / iPageSize)
If nTotalRecords MOD iPageSize <> 0 Then
iTotalPages = iTotalPages + 1
End If

If nTotalRecords <= iPageSize Then
rs.MoveFirst
bOnePage = True
nPageEnd = nTotalRecords
nPageStart = 1
iTotalPages = 1
Else
nPageStart = ((iPage - 1) * iPageSize) + 1
nPageEnd = nPageStart + (iPageSize - 1)

If nPageEnd >= nTotalRecords Then
nPageEnd = nTotalRecords
bLastPage = True
End If

If iPage > 1 Then
rs.AbsolutePosition = ((iPage - 1) * iPageSize) + 1
Else
rs.MoveFirst
End If
End If
Else
bNoRecords = True
End If

If Not bNoRecords Then
out = out & "<P><B>Page " & iPage & " of " & iTotalPages & "</B><P>"
End If

If bNoRecords Then
out = out & "<B>There are no reviews available at the present time</B>"
Else
For lCtr = nPageStart To nPageEnd

'// Start your content code


intID = Rs.Fields("reviewID").Value
out = out & "<a ref=""/moviesite/review.asp?ID=" & intID & """>"

out = out & Rs.Fields("title").Value
out = out & "</a>"
out = out & "<br>"

'// End your content code

rs.movenext
Next
End If

If bOnePage = False And bNoRecords = False Then

If iPage > 1 Then
sPrevQuery = "Page=" & iPage - 1
out = out & "<a href=""page_numbers.asp?" & sPrevQuery & """><B><< Previous Page</B></a>"
Else
out = out & " "
End If

out = out & "<br>"

If bLastPage = False Then
sNextQuery = "Page=" & iPage + 1
out = out & "<a href=""page_numbers.asp?" & sNextQuery & """><B>Next Page >></B></a>"
Else
out = out & " "
End If

out = out & "<br>"

For iCtr = 1 To iTotalPages
sPageQuery = "Page=" & iCtr & sQuery
If iCtr <> iPage Then
out = out & "<a href=""page_numbers.asp?" & sPageQuery & """>"

Else
out = out & "<B>"
End If
out = out & iCtr

If iCtr <> iPage Then
out = out & "</a>"
Else
out = out & "</B>"
End If
If iCtr < iTotalPages Then
out = out & "  |  "
End If
Next
out = out & "</center>"
End If

out = out & "<br>"

If rs.state <> 0 Then
rs.close
End If

'conn.close

Set rs = Nothing
'Set conn = Nothing

PageData = out
End Function

%>

<!---Body--->


 // run your function here


No Comments to show

Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.


Replying to a Comment...


Adding your comment. Please wait...

Thanks for adding your comment!. After further review it will be added.

There was a problem adding your comment. Please try again.

Please complete all the fields in the form before sending.

© 2002 - 2017 snippetlibrary.com All Rights Reserved. Conditions