ASP分页问题,老是出错,真想不通,高手看看。。。

zpwsz 2003-12-13 11:48:56
页面http://17flying.net/web/type.asp,在本地测试时,不管怎么改,第二页老是从第十一条信息开始,也不知怎么回事,改了都没用,页面的源文件http://www.17flying.net/web/type_2.txt,高手看看呀,关键代码:
--------------------------
<%
const MaxPrePage=10 '每页显示记录数
if (request.querystring("page")<>"") and (IsNumeric(request.querystring("page"))) then '检查页号
intPage=CLng(request.querystring("page"))
else
intPage=1
end if

strSql="select * from zkpick where picktype="&CLng(request.querystring("type"))
if (request.querystring("type")<>"") and (IsNumeric(request.querystring("type"))) then '检查是否等级分类
inttype=CLng(request.querystring("type"))
strSql=strSql& " and picktype="&CLng(request.querystring("type"))
else
strSql="select * from zkpick"
end if
strSql=strSql&" order by pickvisitor desc,pickvote desc,pickid desc"

%>
<%
Sub DisplayPagelinks(rs,intPage,intType) '页面导航条
if not(request.querystring("type")<>"") and (IsNumeric(request.querystring("type"))) then
response.write " 全部网站 共有"&rs.RecordCount&"个 "
else
response.write " "&typestr&" 共有"&rs.RecordCount&"个"
end if

if intPage>1 then
if intType<>0 then
response.write "<a href="""&request.ServerVariables("SCRIPT_NAME")&"?type="&intType&"&page=1""><font color='#666666'>首页</font></a> "
response.write "<a href="""&request.ServerVariables("SCRIPT_NAME")&"?type="&intType&"&page="&intPage-1&"""><font color='#666666'>上一页</font></a> "
else
response.write "<a href="""&request.ServerVariables("SCRIPT_NAME")&"?page=1""><font color='#666666'>首页</font></a> "
response.write "<a href="""&request.ServerVariables("SCRIPT_NAME")&"?page="&intPage-1&"""><font color='#666666'>上一页</font></a> "
end if
else
response.write "首页 "
response.write "上一页 "
end if

if intPage < rs.PageCount then
if intType<>0 then
response.write "<a href="""&request.ServerVariables("SCRIPT_NAME")&"?type="&intType&"&page="&intPage+1&"""><font color='#666666'>下一页</font></a> "
response.write "<a href="""&request.ServerVariables("SCRIPT_NAME")&"?type="&intType&"&page="&rs.PageCount&"""><font color='#666666'>尾页</font></a> "
else
response.write "<a href="""&request.ServerVariables("SCRIPT_NAME")&"?page="&intPage+1&"""><font color='#666666'>下一页</font></a> "
response.write "<a href="""&request.ServerVariables("SCRIPT_NAME")&"?page="&rs.PageCount&"""><font color='#666666'>尾页</font></a> "
end if
else
response.write "下一页 "
response.write "尾页 "
end if

'-------------------------------
End Sub
%>
...全文
62 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
seezoo 2004-03-26
  • 打赏
  • 举报
回复
up
seezoo 2003-12-15
  • 打赏
  • 举报
回复
up
aoenzh 2003-12-15
  • 打赏
  • 举报
回复
up
fengc 2003-12-15
  • 打赏
  • 举报
回复
rs.pagesize看看,如"rs.pagesize=10"加在最上部。

下面是的分页代码,可以对照看看。

total=rs.recordcount
rs.PageSize = 10
totalpage=INT(rs.recordcount / rs.PageSize * -1)*-1
if request("page")="" then
rs.absolutepage=1
else
rs.absolutepage=request("page")
end if
nextpage=Cint(rs.absolutepage)+1
backpage=Cint(rs.absolutepage)-1
endpage=Cint(rs.PageSize) * Cint(rs.absolutepage)
beginpage=endpage-Cint(rs.PageSize)+1
if total<endpage then
endpage=total
end if

估计是rs.absolutepage没移动记录。
zpwsz 2003-12-15
  • 打赏
  • 举报
回复
改成MaxPrePage=N,不管N等于都是从第十一条信息开始!
gooddot 2003-12-15
  • 打赏
  • 举报
回复
const MaxPrePage=10 '每页显示记录数

每页显示10条记录,难道第二页不是从第十一条开始吗?
zpwsz 2003-12-15
  • 打赏
  • 举报
回复
如果要全站文件可发E到 seezoo@17flying.net
zpwsz 2003-12-15
  • 打赏
  • 举报
回复
难道这么多人就没看出什么错的吗?
zpwsz 2003-12-15
  • 打赏
  • 举报
回复
大哥们,还是不行呀,能不能能行行好,帮小弟看看源文件错在哪,小弟是刚学ASP的,基本上不会改,已是第三天了,这又赶得急呀!
pimple 2003-12-14
  • 打赏
  • 举报
回复
加一个rs.pagesize试试.
超级大笨狼 2003-12-14
  • 打赏
  • 举报
回复

ASP学习史上最强的数据分页方法

  我观前辈的帖子,皆由于数据库的SQL大不一致,且SQL SERVER,ACCESS等菜鸟级数据库没有如rowid,_n_,obs等之类的辅助列,空有BETWEEN运算符而无用武之地,
又无如except之类的数据集运算符,真是令无数英雄尽折腰



  偶详观各数据库SQL,得出是数据库就有取前面N条记录的SQL语法,如什么select top n*****之类的语法,而数据分页的关键问题是取后N条记录的语法偶深思良久,最后小悟,故出此言,还忘前辈们多多指点
  
  取记录集后N条记录的大法:
  
  假设:
  
   1.有一sql语句将产生1000条记录 (select 唯一ID,其他字段 from 表集 where 条件 order by 排序)
   2.每页显示20条记录
   3.当前显示第5页
  
  实现如下:
   select * from
   (
   select * from (select top 20*4 唯一ID,其他字段 from 表集 where 条件 order by 排序) as a
   union all
   select * from (select top 20*5 唯一ID,其他字段 from 表集 where 条件 order by 排序) as b
   )
   a
   group by 唯一ID,其他字段 having count(唯一ID)=1 order by 排序
  
  运行此SQL,至此取记录集后N条记录大法就些完毕
  
  详细说明:
  
  此SQL语句的关键应用技巧在于union all和分组上的条件过滤语句
  
  大家可以根据此技巧完全可以做出一个通用的分页方法,如直接由用户传入sqlstr(sql语句),NumPerPage(每页显示数),currpage(当前页),自己在再函数内组织成通成的SQL分页语句
  
  备注:
  
  当前页为1的话就不需要运行该SQL了,直接TOP一下就OK了
  由于没有环境,该SQL性能无法测试,但相信不会低效
  运行平台在access,sqlserver上都可运行,其它数据库平台只需改top关键字应该就可以就地运行了




bullion 2003-12-14
  • 打赏
  • 举报
回复
<%
const MaxPrePage=10 '每页显示记录数
if (request.querystring("page")<>"") and (IsNumeric(request.querystring("page"))) then '检查页号
intPage=CLng(request.querystring("page"))
else
intPage=1
end if

strSql="select * from zkpick where picktype="&CLng(request.querystring("type"))
if (request.querystring("type")<>"") and (IsNumeric(request.querystring("type"))) then '检查是否等级分类
inttype=CLng(request.querystring("type"))
strSql=strSql& " and picktype="&CLng(request.querystring("type"))
else
strSql="select * from zkpick"
end if
strSql=strSql&" order by pickvisitor desc,pickvote desc,pickid desc"

%>
<%
Sub DisplayPagelinks(rs,intPage,intType) '页面导航条

rs.pagesize = MaxPrePage

if not(request.querystring("type")<>"") and (IsNumeric(request.querystring("type"))) then
response.write " 全部网站 共有"&rs.RecordCount&"个 "
else
response.write " "&typestr&" 共有"&rs.RecordCount&"个"
end if

if intPage>1 then
if intType<>0 then
response.write "<a href="""&request.ServerVariables("SCRIPT_NAME")&"?type="&intType&"&page=1""><font color='#666666'>首页</font></a> "
response.write "<a href="""&request.ServerVariables("SCRIPT_NAME")&"?type="&intType&"&page="&intPage-1&"""><font color='#666666'>上一页</font></a> "
else
response.write "<a href="""&request.ServerVariables("SCRIPT_NAME")&"?page=1""><font color='#666666'>首页</font></a> "
response.write "<a href="""&request.ServerVariables("SCRIPT_NAME")&"?page="&intPage-1&"""><font color='#666666'>上一页</font></a> "
end if
else
response.write "首页 "
response.write "上一页 "
end if

if intPage < rs.PageCount then
if intType<>0 then
response.write "<a href="""&request.ServerVariables("SCRIPT_NAME")&"?type="&intType&"&page="&intPage+1&"""><font color='#666666'>下一页</font></a> "
response.write "<a href="""&request.ServerVariables("SCRIPT_NAME")&"?type="&intType&"&page="&rs.PageCount&"""><font color='#666666'>尾页</font></a> "
else
response.write "<a href="""&request.ServerVariables("SCRIPT_NAME")&"?page="&intPage+1&"""><font color='#666666'>下一页</font></a> "
response.write "<a href="""&request.ServerVariables("SCRIPT_NAME")&"?page="&rs.PageCount&"""><font color='#666666'>尾页</font></a> "
end if
else
response.write "下一页 "
response.write "尾页 "
end if

'-------------------------------
End Sub
%>
zpwsz 2003-12-14
  • 打赏
  • 举报
回复
''''''''' pimple(╭●ò●╮) : 加一个rs.pagesize试试.

这位仁兄,加在哪呀?
zpwsz 2003-12-14
  • 打赏
  • 举报
回复
大哥们,能不能耗你们点时间帮我把源码看一下,我的页面很多,全部重新做的话太痛苦了!
zl13 2003-12-14
  • 打赏
  • 举报
回复
<%
set rs = server.CreateObject("adodb.recordset")
sql = "select * from kehu"
rs.open sql,conn,1,3

if rs.recordcount>0 then
rs.pagesize=15
page=cint(request("page"))
if page="" then page=1
if page<1 then page=1
if page>= rs.pagecount then page=rs.pagecount
rs.absolutepage=page
for i=1 to rs.pagesize

%>


<TR bgcolor="#ffffff">
<TD><% =rs("name") %></TD>
<TD><% =rs("tel") %></TD>
<TD><% =rs("mo") %></TD>
<TD><% =rs("address") %></TD>
<TD><% =rs("email") %></TD>
<TD><% =rs("linkman") %></TD>
<TD><% =rs("remark") %></TD>
<TD><a onClick="{if(confirm('确定删除吗?')){return true;}return false;}" href=<%
response.write request.servervariables("document_name")&"?page=1&action="&request("action")&"&id="&rs("id") %> >是</a></TD>

</TR>


<%
rs.movenext '纪录指针下移
if rs.eof then exit for '如果到达纪录集底部则退出循环
next
end if
%>
<tr align=center>
<td height=23 colspan=6><%
response.write "每页显示<font color=#ff9900 size=2>"&rs.pagesize&"</font>条记录,共计<font color=#ff9900 size=2>"&rs.recordcount&"</font>条记录,共计<font color=#ff9900 size=2>"&rs.pagecount&"</font>页,当前页<font color=#ff9900 size=2>"&page&"</font>"
if page>1 then
response.write "<a href="&request.servervariables("document_name")&"?page=1&action="&request("action")&"><font size=2>第一页</font></a> "
response.write "<a href="&request.servervariables("document_name")&"?page="&(page-1)&"&action="&request("action")&"><font size=2>上一页</font></a> "
end if
if page<>rs.pagecount then
response.write "<a href="&request.servervariables("document_name")&"?page="&(page+1)&"&action="&request("action")&"><font size=2>下一页</font></a> "
response.write "<a href="&request.servervariables("document_name")&"?page="&rs.pagecount&"&action="&request("action")&"><font size=2>最后一页</font></a> "
Response.Write "<font class='contents'>转到:</font><input type='text' name='page' size=2 maxlength=10 class=smallInput value='"¤tpage&"'>"
Response.Write " <input type='submit' class='contents' value='GO' name='cndok' ></form>"
end if
response.write"<font size=2>页码:"&page&"/"&rs.pagecount&"</font>"

'关闭对象,释放内存
rs.close
set rs=nothing
set rs=nothing
%>

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧