| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 26484 人关注过本帖, 2 人收藏
标题:[原创]刚才做了半天完成的简易分页类
只看楼主 加入收藏
maxianfong
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2005-12-20
收藏
得分:0 
<%
'页面主体循环部分(该部分也可以用户自己用以定义的rs对象来循环或者用本类提供的方法循环)
' Dim FHtml'设定每条记录显示的Html代码(需要动态显示纪录的部分用{字段名}的方式来书写)
FHtml="<tr>"
FHtml=FHtml&"<td width=74 height=16 valign=top><div align=center class=style1>{ID}</div></td>"
FHtml=FHtml&"<td width=96 valign=top><div align=center class=style1>{名字}</div></td>"
FHtml=FHtml&"<td width=142 valign=top><div align=center class=style1>{地址}</div></td>"
FHtml=FHtml&"<td width=135 valign=top><div align=center class=style1>{住宅电话}</div></td>"
FHtml=FHtml&"<td width=152 valign=top><div align=center class=style1>{生日}</div></td>"
FHtml=FHtml&"</tr>"
Response.Write oPage.BodyCyclicTransformation(rsTest,FHtml)'叶面主体循环代码
%>



这么多东西是什么意思呀~~



为什么不用 rs 来做呢?~~ 有点不明白~~

do while not rsTest.eof
。。。。。。。。。。。。。。。

rsTest.MoveNext
Loop

不知道可不可以这样子做~`

2005-12-20 23:23
maxianfong
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2005-12-20
收藏
得分:0 

本人到是有一个还可以~ 不过就是最后一面显示时,有错误

是这样子显示的
9 1 2 3 4 5 6 7 8 9 10 8 : 共有记录10931页/共137 第一页 前一页 下一页


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body>
<% '=============打开数据库表,要以这种方式打开
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from jjzh where flag=1 order by id desc",conn,1,1
%>
<%'=============分页定义开始,要放在数据库打开之后
rs.PageSize=10 '定义每页记录数,可根据实际自定义
PageNo=REQUEST("Page")
recordcount=rs.recordcount
if PageNo="" or PageNo=0 then PageNo=1
RS.AbsolutePage=PageNo
TSum=rs.pagecount
RowCount=rs.PageSize
PageNo=PageNo+1
PageNo=PageNo-1
if CINT(PageNo)>1 then
if CINT(PageNo)>CINT(TSum) then
response.Write("对不起没有您想要的页数")
Response.End
end if
end if
if PageNo<0 then
response.Write("没有这一页!")
Response.End
End if
'=============分页定义结束%>
<%'===========循环体开始
do while iPage<rs.PageSize%>
<table width="559" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="559">
<% title=rs("mr")
if len(title)>100 then title=left(title,98)+"..."
response.write title %>
<a href="gqxx_sk.asp?id=<%=rs("id")%>&fenlei=<%=session("qq")%>">[查看详细信息]</a></td>
</tr>
</table>
<table width="559" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="559"> </td>
</tr>
</table>
<%
rs.movenext
iPage=iPage+1
loop
rs.close '释放资源
set rs=nothing
'===========循环体结束%>
<%'===========过程调用,要放在数据库打开后、释放资源前
call listPages()%>
<%'==========分页过程开始,也可单独创建一文件在本文件前包含调用
sub listPages() '定义过程开始%>
<TABLE width=100% height="5" border=0 align=center cellPadding=3 cellSpacing=0>
<TBODY>
<TR>
<TD width=100% align=center bgcolor="#EEEEEE" style="LETTER-SPACING: 1px">
<%if TSum>10 then
if PageNo mod 10=0 then
currid=PageNo
currid1=PageNo-9
else
if TSum mod 10=0 then
currid=int(PageNo/10)*10+10
else
if int(PageNo/10)=int(TSum/10) then currid=(TSum/10)*10 else currid=int(PageNo/10)*10+10
end if
currid1=int(PageNo/10)*10+1
end if
else
currid=TSum mod 10
currid1=int(TSum/10)*10+1
end if%>
<FONT
face=webdings>
<%if PageNo=1 then%>
<span style="color: #FF0000">9</span>
<%else%>
<a href=<%=request.ServerVariables("script_name")%>?Page=1&fenlei=<% =trim(request("fenlei")) %> title="首页">9</a>
<%end if%>
<%if PageNo>10 then%>
<a href=<%=request.ServerVariables("script_name")%>?Page=<%=currid1-1%>&fenlei=<% =trim(request("fenlei")) %> title="前10页">7</a>
<%end if%>
</FONT><strong>
<%
for i=currid1 to currid
if PageNo=i then
response.Write("<font color=red>"&i&"</font>")
else%>
<a href=<%=request.ServerVariables("script_name")%>?Page=<%=i%>&fenlei=<% =trim(request("fenlei")) %>>
<%response.write i%>
</a>
<%end if%>
<%response.write " "%>
<%next%>
</strong><FONT
face=webdings>
<%if currid<TSum then%>
<a href=<%=request.ServerVariables("script_name")%>?Page=<%=currid+1%>&fenlei=<% =trim(request("fenlei")) %> title="后10页">8</a>
<%end if%>
</FONT> <FONT
face=webdings>
<%if PageNo=TSum then%>
<span style="color: #FF0000">:</span>
<%else%>
<a href=<%=request.ServerVariables("script_name")%>?Page=<%=TSum%>&fenlei=<% =trim(request("fenlei")) %> title="尾页">:</a>
<%end if%>
</FONT>共有记录<font color="#FF0000"><%=recordcount%></font>第<font color="#FF0000"><%=PageNo%></font>页/共<font color="#FF0000"><%=TSum%></font>页<a href=<%=request.ServerVariables("script_name")%>?Page=1>
<%If pagecount<>1 Then
Response.Write "<a href="&request.ServerVariables("script_name")&"?Page=1&fenlei="&trim(request("fenlei"))&">"
End If%>
第一页</a>
<%If pagecount<>1 Then
Response.Write "<a href="&request.ServerVariables("script_name")&"?Page="&(PageNo-1)&"&fenlei="&trim(request("fenlei"))&">"
End If%>
前一页
<%If pagecount<>TSum Then
Response.Write "<a href="&request.ServerVariables("script_name")&"?Page="&(PageNo+1)&"&fenlei="&trim(request("fenlei"))&">"
End If %>
下一页</TD>
</TR>
</TBODY>
</TABLE>
<%
end sub '定义过程结束
'==========分页过程结束%>
</body>
</html>

[此贴子已经被作者于2005-12-20 23:30:54编辑过]

2005-12-20 23:25
dzt0001
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:蒙面侠
威 望:5
帖 子:1281
专家分:4998
注 册:2005-10-12
收藏
得分:0 

----我怎能在别人的苦难面前转过脸去----
2005-12-20 23:29
maxianfong
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2005-12-20
收藏
得分:0 
不好的一点就是

到最后一页时就是报错~ 大家帮看一下呀~~



ADODB.Field 错误 '80020009'

BOF 或 EOF 中有一个是“真”,或者当前的记录已被删除,所需的操作要求一个当前的记录。

/qydq_xb.asp,行 0

2005-12-20 23:32
iamliubo
Rank: 1
等 级:新手上路
帖 子:357
专家分:0
注 册:2005-11-7
收藏
得分:0 
强烈谢谢

2005-12-20 23:37
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:0 
以下是引用maxianfong在2005-12-20 23:32:00的发言:
不好的一点就是

到最后一页时就是报错~ 大家帮看一下呀~~



ADODB.Field 错误 '80020009'

BOF 或 EOF 中有一个是“真”,或者当前的记录已被删除,所需的操作要求一个当前的记录。

/qydq_xb.asp,行 0

不可能呀,我已经改进过了。并经过试验最后一页是不会出错的,虽说算法上还是复杂了一些,但已经经过我的测试没有任何问题。里面的例子程序就是可以用来验证。

2005-12-22 23:28
t_xiang
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2005-12-23
收藏
得分:0 
我是菜鸟

友情帮顶!


2005-12-23 11:35
ziyan
Rank: 1
等 级:新手上路
帖 子:123
专家分:0
注 册:2005-6-29
收藏
得分:0 

谢谢楼主


腰缠十万贯,骑鹤上扬州.玉树琼花,金粉之盛,远过秦淮.晓起凭栏,六代青山尽在眼,晚来把酒,二分明月正当头
2005-12-23 13:54
long00
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2006-4-10
收藏
得分:0 
如果我要查看名字里的信息怎么样加一个链接呀,谢谢回答呢 !!
2006-04-10 21:32
wangjn123
Rank: 1
等 级:新手上路
帖 子:115
专家分:0
注 册:2005-12-5
收藏
得分:0 
收了
谢谢!!

学习中,大家多多帮助!!
2006-04-10 21:41
快速回复:[原创]刚才做了半天完成的简易分页类
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016886 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved