这个分页不是直接将数据库中东西分页现示,而是先筛选,再每页现示一定数量的东西
以下是代码:问题出在,虽然要显示的数量超过每一页能显示的数量的时候,会错现
“下一页”这个按钮,但是点击按钮并不能显示下一页内容
公布的答案
<%
const PgSz=10
const week = 7
set Conn1 = Server.CreateObject("ADODB.Connection")
Conn1.Open "dsn=totejas;uid=sa;pwd=little;database=Kore"
Set RS1 = Server.CreateObject("ADODB.RecordSet")
Set RS2 = Server.CreateObject("ADODB.RecordSet")
sql1 = "SELECT date FROM date "
sql2="select nowtime from nowtime"
RS1.open sql1,Conn1,1,1
RS2.open sql2,Conn1,1,1
dat0=RS1("date")
dat1=RS2("nowtime")
dat=cdate(dat0)
if Year(dat1)>Year(dat) then
n=53+DatePart("ww",dat1)-DatePart("ww",dat)
else
n=DatePart("ww",dat1)-DatePart("ww",dat)
end if
n=n+1
response.write "现在是第"
response.write n
response.write "周"
Response.Write "
"
response.Write titledata
set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "dsn=totejas;uid=sa;pwd=little;database=Kore"
Set RS = Server.CreateObject("ADODB.RecordSet")
sql = "SELECT * FROM answer_all where casttime<="&n&" order by ID "
RS.open sql,Conn,1,1
If RS.RecordCount=0 then
response.write "
对不起,现在没有相关信息"
else
RS.PageSize = Cint(PgSz) '设定PageSize属性的值
Total=INT(RS.recordcount / PgSz * -1)*-1 '计算可显示页面的总数
PageNo=Request("pageno")
if PageNo="" Then
PageNo = 1
else
PageNo=PageNo+1
PageNo=PageNo-1
end if
ScrollAction = Request("ScrollAction")
if ScrollAction = " 上一页 " Then
PageNo=PageNo-1
end if
if ScrollAction = " 下一页 " Then
PageNo=PageNo+1
end if
if PageNo < 1 Then
PageNo = 1
end if
n=1
RS.AbsolutePage = PageNo
position=RS.PageSize*PageNo
pagebegin=position-RS.PageSize+1
if position < RS.RecordCount then
pagend=position
else
pagend= RS.RecordCount
end if
Response.Write "
"&"答案如下:"&" | "
Response.Write "(共有"&RS.RecordCount &"条信息,显示"&pagebegin&"-"&pagend&")"
Response.Write "
"
Do while not (RS is nothing)
RowCount = RS.PageSize
Do While Not RS.EOF and rowcount > 0
If n=1 then
Response.Write ""
ELSE
Response.Write "
"
End If
n=n-1
%>
/<%=RS("name")%>"><%=RS("name")%>
文件描述:<% = RS("description")%>
于第<% = RS("casttime")%>周发布
<%
RowCount=RowCount - 1
RS.MoveNext
Loop
set RS = RS.NextRecordSet
Loop
Conn.Close
set rs = nothing
set Conn = nothing
response.write "
"
%>
">
<%
if PageNo > 1 Then
response.write ""
end if
if RowCount = 0 and PageNo <>Total then
response.write ""
end if
response.write ""
End if
%>
很长,希望大侠们不吝赐教