Originariamente inviato da Roby_72
iNumPerPage da dove arriva???
Roby
E' un codice di paginazione che ho scaricato da un sito...
codice:
<%
Sub PrintRecordsetNav( iNumPerPage, adodbConnection, adodbCommand, sTable, sURL, sQuerystring )
Dim iTtlNumItems, iDBLoc, sSqlTemp, iTtlTemp
Dim iDBLocTemp, sURLBeg, iA, iB, x, iTemp, rsObj
iDBLoc = CInt(Request("iDBLoc"))
iTtlNumItems = CInt(Request("iTtlNumItems"))
' Get ttl num of items from the database if it's not already in the QueryString
if (iTtlNumItems = 0) then
Set rsObj = Server.CreateObject("ADODB.Recordset")
sSqlTemp = "SELECT COUNT(*) FROM " & sTable
adodbCommand.CommandText = sSqlTemp
rsObj.Open adodbCommand
If Not(rsObj.EOF) Then
iTtlNumItems = rsObj(0)
End If
rsObj.Close
Set rsObj = Nothing
end if
iTtlTemp = iTtlNumItems \ iNumPerPage ' this is the number of numbers overall (use the "\" to return int)
iDBLocTemp = iDBLoc \ iNumPerPage ' this is which number we are currently on (use the "\" to return int)
If (sQuerystring <> "") Then
sURLBeg = "<a href = """ & sURL & "?" & sQuerystring & "&iTtlNumItems=" & iTtlNumItems & "&iDBLoc="
Else
sURLBeg = "<a href = """ & sURL & "?iTtlNumItems=" & iTtlNumItems & "&iDBLoc="
End If
'***** BEGIN DISPLAY *****
' Print the "Previous"
if (iDBLoc <> 0) then
Response.Write sURLBeg & (iDBLoc - iNumPerPage) & """>Previous</a> "
end if
' Print the <<
if (iDBLocTemp >= iNumPerPage) then
Response.Write sURLBeg & (( iDBLocTemp \ iNumPerPage ) * iNumPerPage ^ 2) - (iNumPerPage * 9) & """><<</a> "
end if
' Print the numbers in between. Print them out in sets of 10.
iA = ( iDBLocTemp \ iNumPerPage ) * iNumPerPage
iB = ( iDBLocTemp \ iNumPerPage ) * iNumPerPage + iNumPerPage
for x = iA to iB
iTemp = (x * iNumPerPage)
if (iTemp < iTtlNumItems) then ' takes care of extra numbers after the overall final number
if (iDBLoc = iTemp) then
Response.Write " [" & x+1 & "]"
else
Response.Write " " & sURLBeg & (x * iNumPerPage) & """>" & x+1 & "</a>"
end if
else
exit for
end if
next
' Print the >>
if (iTtlTemp > iDBLocTemp) then
if ((iDBLocTemp + iNumPerPage) <= iTtlTemp) then
Response.Write " " & sURLBeg & (( iDBLocTemp \ iNumPerPage ) * iNumPerPage + iNumPerPage ) * iNumPerPage & """>>></a> "
end if
end if
' Print the "Next"
if ((iDBLoc + iNumPerPage) < iTtlNumItems) then
Response.Write " " & sURLBeg & (iDBLoc + iNumPerPage) & """>Next</a>"
end if
'***** END DISPLAY *****
End Sub
%>