分页程序点击下一页还是第一页的信息,为什么 5
<%dimcn,rs,sql,i,biaoti,nbaseclass="200"setcn=Server.CreateObject("adodb.Connection")...
<%
dim cn, rs, sql, i, biaoti, n
baseclass = "200"
set cn = Server.CreateObject("adodb.Connection")
set rs = Server.CreateObject("adodb.Recordset")
cn.Open mycnstr
classcode = Request.QueryString("classcode")
pageno = toInt(Request.QueryString("pageno"), 1, "")
if not isnumeric(classcode) then classcode = ""
if classcode="" then
sql="select top 1 classcode,classname from miscell_class where baseclass='"+baseclass+"' and flag='0' order by sortnum"
else
sql="select classcode,classname from miscell_class where classcode='"+classcode+"' and flag='0'"
end if
rs.Open sql,cn,0,1,1
if not rs.EOF then
classcode=rs(0)
classname=trim(rs(1))
else
Response.Redirect "default.asp"
end if
rs.Close
%>
<%
sql="select keyno,title,creadate,querycount from miscell where classcode='" & classcode & "' and state='1' order by sortnum desc"
rs.Open sql,cn,1,1,1
pagesize = 6
rs.PageSize=pagesize
pagecount = rs.PageCount
recordcount = rs.RecordCount
pageno = toInt(pageno, 1, pagecount)
if pageno > 1 then rs.AbsolutePage = pageno
i=1
do while not rs.EOF and i<=pagesize
biaoti= rs("title")
%>
''显示新闻列表
<%
i = i + 1
rs.MoveNext
loop
rs.Close
%>
<% If Request("Page")<>"" and Session("Page")<>Request("Page") Then Session("Page")=Request("Page")
If Session("Page")="" Then Session("Page")=1
If Request("Point")<>"" and Session("Point")<>Request("Point") Then Session("Point")=Request("Point")
If Session("Point")<2 Then Session("Point")=2
If Session("Point")="" Then Session("Point")=14
%>
<%
If (recordcount mod pagesize)=0 Then
n= recordcount\pagesize
Else
n= recordcount\pagesize +1
End If
%>
<form action="news-sj.asp" method=Post class="Text_Black">
<div align="center">
共<b> </b><b><%=recordcount%></b>项
<%If Session("Page")<2 Then%>
<font color="#999999">首页</font> <font color="#999999">上一页</font>
<%Else%>
<a href="news-sj.asp?Page=1" class="List_Black">首页</a> <a href="news-sj.asp?Page=<%=Session("Page")-1%>" class="List_Black">上一页</a>
<%
End If
If n-Session("Page")<1 Then
%>
<font color="#999999">下一页</font> <font color="#999999">末页</font>
<%Else%>
<a href="news-sj.asp?Page=<%=Session("Page")+1%>" class="List_Black">下一页</a> <a href="news-sj.asp?Page=<%=n%>" class="List_Black">末页</a>
<%End If%>
页次:<strong><%=Session("Page")%>/<%=n%></strong>页 转到: 第
<input name="Page" size="6" value="<%=Session("Page")%>">
页
<input type="submit" value="GO" name="Change_Page" class="Text_Black">
</form>
新闻可以正常显示,分页时点击下一页取出来的还是第一页那几条新闻 展开
dim cn, rs, sql, i, biaoti, n
baseclass = "200"
set cn = Server.CreateObject("adodb.Connection")
set rs = Server.CreateObject("adodb.Recordset")
cn.Open mycnstr
classcode = Request.QueryString("classcode")
pageno = toInt(Request.QueryString("pageno"), 1, "")
if not isnumeric(classcode) then classcode = ""
if classcode="" then
sql="select top 1 classcode,classname from miscell_class where baseclass='"+baseclass+"' and flag='0' order by sortnum"
else
sql="select classcode,classname from miscell_class where classcode='"+classcode+"' and flag='0'"
end if
rs.Open sql,cn,0,1,1
if not rs.EOF then
classcode=rs(0)
classname=trim(rs(1))
else
Response.Redirect "default.asp"
end if
rs.Close
%>
<%
sql="select keyno,title,creadate,querycount from miscell where classcode='" & classcode & "' and state='1' order by sortnum desc"
rs.Open sql,cn,1,1,1
pagesize = 6
rs.PageSize=pagesize
pagecount = rs.PageCount
recordcount = rs.RecordCount
pageno = toInt(pageno, 1, pagecount)
if pageno > 1 then rs.AbsolutePage = pageno
i=1
do while not rs.EOF and i<=pagesize
biaoti= rs("title")
%>
''显示新闻列表
<%
i = i + 1
rs.MoveNext
loop
rs.Close
%>
<% If Request("Page")<>"" and Session("Page")<>Request("Page") Then Session("Page")=Request("Page")
If Session("Page")="" Then Session("Page")=1
If Request("Point")<>"" and Session("Point")<>Request("Point") Then Session("Point")=Request("Point")
If Session("Point")<2 Then Session("Point")=2
If Session("Point")="" Then Session("Point")=14
%>
<%
If (recordcount mod pagesize)=0 Then
n= recordcount\pagesize
Else
n= recordcount\pagesize +1
End If
%>
<form action="news-sj.asp" method=Post class="Text_Black">
<div align="center">
共<b> </b><b><%=recordcount%></b>项
<%If Session("Page")<2 Then%>
<font color="#999999">首页</font> <font color="#999999">上一页</font>
<%Else%>
<a href="news-sj.asp?Page=1" class="List_Black">首页</a> <a href="news-sj.asp?Page=<%=Session("Page")-1%>" class="List_Black">上一页</a>
<%
End If
If n-Session("Page")<1 Then
%>
<font color="#999999">下一页</font> <font color="#999999">末页</font>
<%Else%>
<a href="news-sj.asp?Page=<%=Session("Page")+1%>" class="List_Black">下一页</a> <a href="news-sj.asp?Page=<%=n%>" class="List_Black">末页</a>
<%End If%>
页次:<strong><%=Session("Page")%>/<%=n%></strong>页 转到: 第
<input name="Page" size="6" value="<%=Session("Page")%>">
页
<input type="submit" value="GO" name="Change_Page" class="Text_Black">
</form>
新闻可以正常显示,分页时点击下一页取出来的还是第一页那几条新闻 展开
1个回答
展开全部
为什么用session?这样好像绕了圈子?给个例子,你试着改改看吧:
page = request.querystring("page")
if page="" then page="1"
page=cint(page)
rs.open "...",cn,1,3 '这句是读取新闻的
if rs.recordcount>1 then
rs.pagesize = 6
rs.absolutepage = page
i = rs.pagesize
do while not rs.eof and i>0
i=i-1
'输出新闻
rs.movenext
loop
if page>1 then
response.write "<a href='news-sj.asp?page=1'>首页</a> <a href='news-sj.asp?page="&(page-1)&"'>上一页</a>"
end if
for i=1 to rs.pagecount
response.write " <a href='news-sj.asp?page="&i&"'>"&i&"</a>"
next
if page<rs.pagecount then
response.write "<a href='news-sj.asp?page="&(page+1)&"'>下一页</a> <a href='news-sj.asp?page="&rs.pagecount&"'>尾页</a>"
end if
end if
page = request.querystring("page")
if page="" then page="1"
page=cint(page)
rs.open "...",cn,1,3 '这句是读取新闻的
if rs.recordcount>1 then
rs.pagesize = 6
rs.absolutepage = page
i = rs.pagesize
do while not rs.eof and i>0
i=i-1
'输出新闻
rs.movenext
loop
if page>1 then
response.write "<a href='news-sj.asp?page=1'>首页</a> <a href='news-sj.asp?page="&(page-1)&"'>上一页</a>"
end if
for i=1 to rs.pagecount
response.write " <a href='news-sj.asp?page="&i&"'>"&i&"</a>"
next
if page<rs.pagecount then
response.write "<a href='news-sj.asp?page="&(page+1)&"'>下一页</a> <a href='news-sj.asp?page="&rs.pagecount&"'>尾页</a>"
end if
end if
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询