| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2660 人关注过本帖
标题:分页显示求助
只看楼主 加入收藏
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:0 
我刚才已经做好了一个简易分页类,虽然简易,但是修改修改就能用在任何地方。
http://bbs.bc-cn.net/bbs/dispbbs.asp?boardID=10&ID=37557&page=1
2005-12-09 22:39
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:27
maxianfong
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2005-12-20
收藏
得分:0 



送一个给大家吧~~
http://www.gxxsw.com
http://www.gxhf.com
http://www.chjjw.com

我自己也用的

<%
'声明数据库记录集对象
Dim rsAREAL
'创建数据库记录集对象
Set rsAREAL=Server.CreateObject("ADODB.Recordset")
'设定数据库记录集游标类型
rsAREAL.cursortype=3
'打开记录集对象
rsAREAL.Open "select * from NewsData where D_CataID='"&cataid&"' order by D_ID desc",conn
'设定每页显示记录数
rsAREAL.pagesize=18
'得到请求的页号
page=1
IF request("page")<>"" then
page=clng(request("page"))
Else
page=1
End IF
IF page<1 Then page=1
If page>rsAREAL.pagecount Then page=rsAREAL.pagecount
rsAREAL.absolutepage=page
%>

<%'=LMA.JavaScript%>
<table width="100%" border="0" cellpadding="4" cellspacing="0">
<% do while not rsAREAL.eof and i<rsAREAL.pagesize %>
<tr>
<td width="3%">·</td>
<td width="97%" class="ty0" > <a href="jjxg_sk.asp?id=<%=rs("D_ID")%>&cataid=<%=rsAREAL("D_CataID")%>" target="_blank" class="a3">
<% =rsAREAL("D_Title")
%>
</a>
<%
title=rsAREAL("D_SaveFileName")
if len(title)>5 then
%>
<img src="image/news.gif" width="16" height="11">
<%else%>
<%end if%>
</td>
</tr>
<%
i=i+1
rsAREAL.movenext
loop
%>
</table>
<table width="98%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="15" colspan="3" valign="top"><p align="right" class="style2">共<%=rsAREAL.pagecount%>页  当前第<font color="#FF0000"> </font><font color="#FF0000"><%=page%></font> 页 分页:<a href="jjxg_xb.asp?page=1&PageP=10&cataid=<%=trim(request("cataid"))%>" title="第一页" target="_self"><font face=webdings>9</font></a>
<%
Dim PageP
Dim fp
'stop
IF page<>1 Then
IF Request("PageP")="" Then
Response.Write "<a href=jjxg_xb.asp?page="&(page-1)&"&PageP="&(page+9)&"&cataid="&cataid&" title=上一页 target=_self><font face=webdings>7</font></A>"
Else
PageP=Clng(Request("PageP"))
IF page>=PageP Then
Response.Write "<a href=jjxg_xb.asp?page="&(page-1)&"&PageP="&(page+9)&"&cataid="&cataid&" title=上一页 target=_self><font face=webdings>7</font></A>"
Else
IF page=(PageP-10) Then
Response.Write "<a href=jjxg_xb.asp?page="&(page-1)&"&PageP="&(PageP-9)&"&cataid="&cataid&" title=上一页 target=_self><font face=webdings>7</font></A>"
PageP=PageP-9
Else
Response.Write "<a href=jjxg_xb.asp?page="&(page-1)&"&PageP="&PageP&"&cataid="&cataid&" title=上一页 target=_self><font face=webdings>7</font></A>"
End IF
End IF
End IF
Else
Response.Write "<font face=webdings>7</font>"
End IF
IF Request("PageP")="" Then
For fp=page To (page+9)
IF fp<rsAREAL.pagecount Then
Response.Write "<a href=jjxg_xb.asp?page="&CStr(fp)&"&PageP="&CStr(page+9)&"&cataid="&cataid&" target=_self>"&CStr(fp)&"</a> "
End IF
Next
Else
'PageP=Clng(Request("PageP"))
IF page>=PageP Then
For fp=page To page+9
IF fp<rsAREAL.pagecount Then
Response.Write "<a href=jjxg_xb.asp?page="&CStr(fp)&"&PageP="&CStr(page+9)&"&cataid="&cataid&" target=_self>"&CStr(fp)&"</a> "
End IF
Next
'Response.Write "PD"
Else
IF page=(PageP-9) Then
IF page<>1 Then
For fp=(page-9) To (page-9)+9
IF fp<rsAREAL.pagecount Then
Response.Write "<a href=jjxg_xb.asp?page="&CStr(fp)&"&PageP="&CStr((page-9)+9)&"&cataid="&cataid&" target=_self>"&CStr(fp)&"</a> "
End IF
Next
Else
For fp=1 To 1+9
IF fp<rsAREAL.pagecount Then
Response.Write "<a href=jjxg_xb.asp?page="&CStr(fp)&"&PageP="&CStr(1+9)&"&cataid="&cataid&" target=_self>"&CStr(fp)&"</a> "
End IF
Next
End IF
Else
For fp=(PageP-9) To (PageP-9)+9
IF fp<rsAREAL.pagecount Then
Response.Write "<a href=jjxg_xb.asp?page="&CStr(fp)&"&PageP="&CStr(PageP)&"&cataid="&cataid&" target=_self>"&CStr(fp)&"</a> "
End IF
Next
End IF
'Response.Write "PF"&CStr((PageP-9)+9)&","&CStr(PageP-9)
End IF
End IF
IF page<>rsAREAL.pagecount Then
IF Request("PageP")="" Then
Response.Write "<a href=jjxg_xb.asp?page="&(page+1)&"&PageP="&(page+9)&"&cataid="&cataid&" title=下一页 target=_self><font face=webdings>8</font></A>"
Else
IF page>=PageP Then
Response.Write "<a href=jjxg_xb.asp?page="&(page+1)&"&PageP="&(page+9)&"&cataid="&cataid&" title=下一页 target=_self><font face=webdings>8</font></A>"
Else
Response.Write "<a href=jjxg_xb.asp?page="&(page+1)&"&PageP="&Request("PageP")&"&cataid="&cataid&" title=下一页 target=_self><font face=webdings>8</font></A>"
End IF
End IF
Else
Response.Write "<font face=webdings>8</font>"
End IF
%>
<a href="jjxg_xb.asp?page=<%=rsAREAL.pagecount%>&PageP=<%=(rsAREAL.pagecount+3)%>&cataid=<%=trim(request("cataid"))%>" title="最后一页" target="_self"><font face=webdings>:</font></a></p></td>
</tr>
</table>

2005-12-21 01:17
快速回复:分页显示求助
数据加载中...
 
   



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

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