效果:
首页 上十 上一 11 12 13 14 15 16 17 18 19 20 下一 下十 尾页 转到___
11/20页 963篇
主文件: dateview.asp , 查询参数 yearview=, 分页参数 pageview=
包含文件: abbr.asp
dateview.asp?yearview=2004&pageivew=1
---/-------------------------------------------------------------------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="include/abbr.asp" -->
<script language="JavaScript" type="text/JavaScript">
<!--// 页面跳转脚本
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
<% '查询年份分页 dateview.asp?yearview=2004&pageivew=1
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' subject : ASP 分页操作, 改良版 by Stabx
'
' author : Stabx<shawl.qiu@gmail.com>
'
' blog : http://blog.csdn.net/btbtd \ http://btbtd.exblog.jp/
'
' blog name : Phoenix.GI - P.GI
'
' date : 2006-4-21
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' rsn.PageCount / 总页数
' pageview / 当前页数
Dim I '定义循环变量
Dim RPP 'RPP:指定每页显示的记录数,
Dim pageview '翻页变量
I=1 '从 1 开始
RPP=50 '每页显示 50 条记录
pageview=CInt(Request("pageview")) '读取 URL 页号
Dim rsn '定义链接名
Set rsn = Server.CreateObject("ADODB.Recordset") '建立一个 rsn 数据库查询
rsn.ActiveConnection = MM_conn_STRING 'rsn 链接方式, 这是 DW 的链接字符串
rsn.Source = "select article.*, class.*, nclass.* from article, class, nclass where article.classid=class.classid and article.nclassid=nclass.nclassid and year(dateandtime)="&request.QueryString("yearview")&" order by dateandtime asc"
' rsn 查询语句, SELECT 所有列 FROM 表 WHERE 条件 ORDER BY 条件
rsn.CursorType = 1 '游标属性
rsn.CursorLocation = 2 '游标位置
rsn.LockType = 1 '定义数据库查询模式
rsn.Open() '打开数据库链接
rsn.PageSize=RPP '定义每页显示记录数
If pageview<=0 Then pageview=1 '如果 pageview 小于或等于0, 返回值1
If pageview>rsn.PageCount Then pageview=rsn.PageCount ' 如果 pageview 大于分页总数, 返回分页末页值
rsn.AbsolutePage=pageview '定义当前页码
Sub ShowPageInfo(tPageCount,cPageNo) '定义子例程 ShowPageInfo, 显示页数和总页
Response.Write cPageNo&"/"&tPageCount&"页" '显示当前页和总页数
End Sub
Sub ShowPageNavi(tPageCount,cPageNo) ' 定义子例程 ShowPageNavi, 显示分页号
If cPageNo<1 Then cPageNo=1 '如果页数小于 1, 默认为 1; 当前页, cPageNo = Current Page NO.
If tPageCount<1 Then tPageCount=1
If cPageNo>tPageCount Then cPageNo=tPageCount
Dim NaviLength
NaviLength=10 ' 显示数字链接数
Dim I,StartPage,EndPage ' 定义当前页, 开始页, 结束页
StartPage=(cPageNo\NaviLength)*NaviLength+1 '为开始页赋值
if pageview=1 then '判断是否首页, 如果是首页不添加链接,反之添加.
Response.Write "<font color=""#CCCCCC"">首页</font> " '显示没有添加链接热点的"首页"
Else
Response.Write "<a href="&dyv_&rqsyv_&dyvpv_&"1>首页</a> " '首页链接
End If
If (cPageNo Mod NaviLength)=0 Then StartPage=StartPage-NaviLength
EndPage=StartPage+NaviLength-1
If EndPage>tPageCount Then EndPage=tPageCount
If StartPage>1 Then '向后移动一分页, 十页为一分页, 并且以 1, 11, 21... 为每页的开始篇数
Response.Write "<a href="&dyv_&rqsyv_&dyvpv_&(cPageNo-(cPageNo mod 10)-NaviLength+1)&">"&previous10_&"</a> "
Else
Response.Write "<font color=""#CCCCCC"">"&previous10_&"</font> "
End If
If pageview <> 1 and pageview <>0 Then '后移一页
Response.Write "<a href="&dyv_&rqsyv_&dyvpv_&(pageview-1)&">"&previous1_&"</a> "
Else
Response.Write "<font color=""#CCCCCC"">"&previous1_&"</font> "
End If
For I=StartPage To EndPage
If I=cPageNo Then
Response.Write "<b>"&I&"</b>"
Else
Response.Write "<a href="&dyv_&rqsyv_&dyvpv_& I & ">" & I & "</a>"
End If
If I<>tPageCount Then Response.Write " "
Next
If pageview <> rsn.PageCount and pageview <>0 Then '前移一页
Response.Write " <a href="&dyv_&rqsyv_&dyvpv_&(pageview+1)&">"&next1_&"</a> "
Else
Response.Write "<font color=""#CCCCCC"">"&next1_&"</font> "
End If
If EndPage<tPageCount Then '向前移动一分页, 十页为一分页, 并且以 1, 11, 21 为每页的开始篇数
Response.Write " <a href="&dyv_&rqsyv_&dyvpv_&(cPageNo-(cPageNo mod 10)+NaviLength+1)&">"&next10_&"</a> "
Else
Response.Write " <font color=#CCCCCC>"&next10_&"</font> "
End If
if rsn.PageCount<>pageview then '判断是否尾页
Response.Write "<a href="&dyv_&rqsyv_&dyvpv_&rsn.PageCount&">尾页</a>"
Else
Response.Write "<font color=""#CCCCCC"">尾页</font>"
End If
End Sub
%>
<div CLASS="center">
<form NAME="pageform" ID="pageform">
<% showPageNavi rsn.PageCount,pageview %>
<select NAME="menu1" onChange="MM_jumpMenu('parent',this,0)">
<% for i=1 to rsn.PageCount %>
<option VALUE="<%=dyv_&rqsyv_&dyvpv_&i%>"
<% if pageview=i then%> selected <%end if%>>
第<%=i%>页
</option>
<%next%>
</select>
</form>
<% showPageInfo rsn.PageCount,pageview %> <% Response.Write(rsn.RecordCount) %>篇<br />
</div>
<%
If rsn.EOF OR rsn.BOF Then
Else
For I=1 To rsn.PageCount
%>
<%=(pageview-1)*RPP+I%>
<%=rsn("dateandtime")%> <a href="<%=a1_&rsn("article.classid")&a2_&rsn("article.nclassid")&a3_&rsn("articleid")%>"><%= rsn("title") %></a><p/>
<%
rsn.MoveNext
If rsn.EOF OR rsn.BOF Then Exit For
Next
End If
%>
<div CLASS="center">
<form NAME="pageform" ID="pageform">
<% showPageNavi rsn.PageCount,pageview %>
<select NAME="menu1" onChange="MM_jumpMenu('parent',this,0)">
<% for i=1 to rsn.PageCount %>