| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 675 人关注过本帖
标题:[求助]谁可以把这段不错的分页代码~转换成函数Function 或者告诉我怎么改`` ...
只看楼主 加入收藏
kong11623756
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2006-3-15
收藏
 问题点数:0 回复次数:3 
[求助]谁可以把这段不错的分页代码~转换成函数Function 或者告诉我怎么改``谢谢

<%
Set rs= Server.CreateObject("ADODB.Recordset")
sql="select * from download where bigclassname='产品中心' and smallclassname='儿科类' order by id desc"
rs.open sql,conn,1,1
lendnum=0
const MaxPerPage=6
if rs.eof and rs.bof then
response.write("<font color='red'>现在没有任何记录,请到后台添加</font>")
response.End()
end if
rs.MoveFirst '注意放到前面来,否则到任何页总是在第一个记录上
rs.pagesize=MaxPerPage '设置每页最多显示多少条记录
If trim(Request("Page"))<>"" then '如果请求的页次不为空
CurrentPage= CLng(request("Page")) 'clng是转换成长整型数据类型,并赋值到当前页次上
If CurrentPage> rs.PageCount then '如果当前页次大于总页数,则将最大页次赋值到当前页次上
CurrentPage = rs.PageCount
End If
Else
CurrentPage= 1 '一切条件不成立,将当前页设为第一页
if session("page")<>"" then
CurrentPage=session("page")
end if
End If
totalPut=rs.recordcount '将总记录赋值于TOTALPUT
if CurrentPage<>1 then '如果当前页数不等于第一页
if (currentPage-1)*MaxPerPage<totalPut then '如果当前页减一乘以每页最大的记录数小于总记录的话
rs.move(currentPage-1)*MaxPerPage '相对当前记录数向后移动
dim bookmark '定义书签变量
bookmark=rs.bookmark '将当前记录的标签赋于变量BOOKMARK上
end if
end if

dim n,k
if (totalPut mod MaxPerPage)=0 then '总记录数与每页最大记录数求余的结果为零时,则N返回整数页次,否则再加一.
n= totalPut \ MaxPerPage
else
n= totalPut \ MaxPerPage + 1
end if
do while not rs.eof and lendnum<MaxPerPage
lendnum=lendnum+1
nN=nN+1
%>
<%=rs("title")%>
<%
rs.movenext
loop
%>
<form method=POST action="pro.asp" name=setPagesList>
<!-- 分页显示代码块 可独立使用,注意和上面分页功能代码配使用 -->
共有<font color="#FF0000"><%=rs.recordcount%></font>条记录 
<%
k=currentPage
if k<>1 then
response.write "|<b>"+"<a href='?page=1'>首页</a></b>| "
response.write "<b>"+"<a href='?page="&cstr(k-1)&"&px="&px&"'>上一页</a></b>| "
else
Response.Write "|首页|上一页|"
end if
if k<>n then
response.write "<b>"+"<a href='?page="&cstr(k+1)&"'>下一页</a></b>| "
response.write "<b>"+"<a href='?page="&cstr(n)&"'>尾页</a></b>| "
else
Response.Write "下一页|尾页|"
end if
%>
第<font color="#FF0000"><%=currentpage%></font>/<%=n%>页&nbsp;转到<input name=page type=text class="loginfrom" value="<%=currentpage %>" size=3 maxlength=3>页
</form>

搜索更多相关主题的帖子: Function 函数 代码 
2007-08-08 17:36
kong11623756
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2006-3-15
收藏
得分:0 
怎么没人顶啊```~~

怎么写函数啊 `???`````555555555555555555555
2007-08-08 21:23
yutaozj
Rank: 1
等 级:新手上路
威 望:1
帖 子:234
专家分:0
注 册:2006-2-17
收藏
得分:0 
我自己也写了一个,你可以参考下
K7k4ApKj.txt (2.63 KB) [求助]谁可以把这段不错的分页代码~转换成函数Function 或者告诉我怎么改``谢谢



愿天下所有的人都喜欢编程~!@¥#%……&*(——+
2007-08-09 15:25
都市打工者
Rank: 1
等 级:新手上路
帖 子:177
专家分:0
注 册:2007-8-7
收藏
得分:0 
楼上的这个我也早用了,效果不错的。后面可以跟很多参数的

做好自己工作的每一天,与朋友乐
2007-08-09 17:27
快速回复:[求助]谁可以把这段不错的分页代码~转换成函数Function 或者告诉我怎么 ...
数据加载中...
 
   



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

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