一聚教程网:一个值得你收藏的教程网站

热门教程

asp 分页代码

时间:2022-07-02 23:05:48 编辑:袖梨 来源:一聚教程网

长一段时间,我发现搜索的方式,我想我的结果页,但现在的问题是它does'nt显示所有的拇指的权利所有人不向拇指链接大部分是正确的。
谁能帮助我。 o和为瑟姆斯他得到了一个数据库连接

<%
Option Explicit
'declare variables
Dim Currpage, pageLen, lastNumber, PageRem, PageTen
Dim connection, recordset, sSQL, sConnString, next10, prev10, P
Dim RSPrevPage, RSNextPage, start
'Get the current page the user is on, if it's the first time they
'visit and the variable 'PageNo' is empty, then 'CurrPage' gets set to 1
'Else the current page variable 'CurrPage' is set to the page number requested
If IsEmpty(Request.Querystring("PageNo")) then
CurrPage = 1
Else
CurrPage = Cint(Request.Querystring("PageNo"))
End If

'the two functions below return the next 10 and prev 10 page number
Function getNext10(num)
pageLen = len(num)
If pageLen = 1 Then
next10 = 10
Else If pageLen>1 Then
pageRem = 10
pageTen = right(num, 1)
next10 = num + pageRem - pageTen
End If
End If
getNext10 = next10
End Function

Function getPrev10(num)
pageLen = len(num)
If pageLen = 1 then
prev10 = 1
Else If pageLen>1 then
lastNumber = right(num, 1)
prev10 = num - lastNumber - 10
End If
End If
If prev10 = 0 then
prev10 = 1
End If
getPrev10 = prev10
End Function

'create an instance of the ADO connection and recordset object
Set Connection = Server.CreateObject("ADODB.Connection")
Set Recordset = Server.CreateObject("ADODB.Recordset")

'define the connection string
sConnString = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
"DBQ=" & Server.MapPath("db.mdb") & ";"

'define our SQL variable
sSQL="SELECT * FROM tbl_content WHERE plantnaam LIKE 'A%' ORDER BY [plantnaam] ASC"

'open an active connection
Connection.Open sConnString

'Next set the location of the recordset to the client side
Recordset.CursorLocation = 3

'Execute the SQL and return our recordset
Recordset.open sSQL, sConnString
' pagesize is used to set the number of records that will be
' displayed on each page. For our purposes 10 records is what we want.
Recordset.PageSize = 14
%>


Recordset Paging Script


<%
'get the next 10 and prev 10 page number
next10 = getNext10(CurrPage)
prev10 = getPrev10(CurrPage)

'the next 2 lines setup the page number for the "previous" and "next" links
RSPrevPage = CurrPage -1
RSNextPage = CurrPage + 1

'find out the number of pages returned in the recordset
'if the Next10 page number is greater than the recordset page count
'then set Next10 to the recordset pagecount
If Next10 > Recordset.PageCount Then
Next10 = Recordset.PageCount
End If

'the variable start determines where to start the page number navigation
' i.e. 1, 10, 20, 30 and so on.
If prev10 = 1 AND next10 - 1 < 10 Then
start = 1
Else
start = Next10 - 14
If right(start, 1) > 0 Then
start = replace(start, right(start, 1), "0")
start = start + 14
End If
End If

'This checks to make sure that there is more than one page of results
If Recordset.PageCount > 1 Then
'Work out whether to show the Previous 10 '<<'
If currpage > 1 Then
response.write("<< ")
End If
'Work out whether to show the Previous link '<'
If NOT RSPrevPage = 0 then
response.write("< ")
End If

'Loop through the page number navigation using P as our loopcounter variable
For P = start to Next10

If NOT P = CurrPage then
response.write("" & P & " ")
Else
'Don't hyperlink the current page number
response.write(" " & P & " ")
End If
Next
'this does the same as the "previous" link, but for the "next" link
If NOT RSNextPage > Recordset.PageCount Then
response.write("> ")
End If

'Work out whether to show the Next 10 '>>'
If NOT Next10 = Recordset.PageCount Then
response.write(" >>

")
End If
End If


'If there are no records
If Recordset.EOF Then
Response.write "No records to display"

Else
'this moves the record pointer to the first record of the current page
Recordset.AbsolutePage = CurrPage

'the below loop will loop until all the records of the current page have been
'displayed or it has reached the end of the recordset
Do Until Recordset.AbsolutePage <> CurrPage OR Recordset.Eof

'for our purposes our database has just 3 fields:
'an 'ID' (autonumber field), 'SiteName' (textfield) and 'URL' (memofield)
'you can change these according to your database and table fields
response.write "" & Recordset ("plantnaam") & "

"
response.write "


"

Recordset.MoveNext
Loop

End If

'the next 2 lines setup the page number for the "previous" and "next" links
RSPrevPage = CurrPage -1
RSNextPage = CurrPage + 1

'find out the number of pages returned in the recordset
'if the Next10 page number is greater than the recordset page count
'then set Next10 to the recordset pagecount
If Next10 > Recordset.PageCount Then
Next10 = Recordset.PageCount
End If

'the variable start determines where to start the page number navigation
' i.e. 1, 10, 20, 30 and so on.
If prev10 = 1 AND next10 - 1 < 10 Then
start = 1
Else
start = Next10 - 10
If right(start, 1) > 0 Then
start = replace(start, right(start, 1), "0")
start = start + 10
End If
End If

'This checks to make sure that there is more than one page of results
If Recordset.PageCount > 1 Then
'Work out whether to show the Previous 10 '<<'
If currpage > 1 Then
response.write("<< ")
End If
'Work out whether to show the Previous link '<'
If NOT RSPrevPage = 0 then
response.write("< ")
End If

'Loop through the page number navigation using P as our loopcounter variable
For P = start to Next10

If NOT P = CurrPage then
response.write("" & P & " ")
Else
'Don't hyperlink the current page number
response.write(" " & P & " ")
End If
Next
'this does the same as the "previous" link, but for the "next" link
If NOT RSNextPage > Recordset.PageCount Then
response.write("> ")
End If

'Work out whether to show the Next 10 '>>'
If NOT Next10 = Recordset.PageCount Then
response.write(" >>")
End If
End If

' Close the recordset and connection object
Recordset.Close
Set Recordset = Nothing
Connection.Close
Set Recordset =Nothing
%>

热门栏目