ASP 通用文章分页函数(非记录集分页), 返回多个结果, 字典实现 By shawl.qiu
2006-09-04 10:54
911 查看
ASP 通用文章分页函数(非记录集分页), 返回多个结果, 字典实现 By shawl.qiu
说明:本函数为文章分页, 非记录集分页
本函数实现将文章分页显示, 并以指定长度显示每一分页
本函数实现不需指定 URL, 自动更替 URL
本函数实现返回多个结果, 为: 分页链接-文章统计信息-文章内容, 由字典实现
如果分页大小大于文章总大小, 分页链接将为空.
显示如:
第1页 第2页 第3页 第4页 第5页
50,000字/页 1/5页 共235,289字
正文...
注: 显示内容的三个元素可自由变更位置.
附注:
如果您是在查找 记录集分页函数, 鄙人以前也写过一个, 名为 "ASP VBScript 分页函数 by Stabx, 第三版".
链接: http://blog.csdn.net/btbtd/archive/2006/05/31/765595.aspx
shawl.qiu
2006-09-04
http://blog.csdn.net/btbtd
主内容: 分页函数及调用代码
linenum
<%
dim rs, dic
set rs=createObject("adodb.recordset")
rs.open "select * from ctat where aid=15783",conn
'rs.open "select * from ctat where aid=12850",conn
set dic=fAtPgnt(rs("content"),50000,request.queryString("apid"))
response.write dic("pgnt")&"<br/>"
response.write dic("info")&"<br/>"
response.write dic("cnt")&"<br/>"
set dic=nothing
rs.close
set rs=nothing
function fAtPgnt(aStr,pSize,rId)
''''''''''''''''''''''''''''''''''''''''''''''''''''''
'ASP 通用文章分页函数(非记录集分页), 返回多个结果, 字典实现 By shawl.qiu
' http://blog.csdn.net/btbtd
'2006-09-04
'''''''''''''''''''''''''''
'输入参数说明:
'aStr 为要分页的字符串
'pSize 为每页大小数字
'rId 为 URL 参数 ID, 默认为 apid, 由函数里的 rName 变量定义
'''''''''''''''''''''''''''
'输出参数说明:
'obj("pgnt") 为文章翻页链接
'obj("info") 为文章统计信息
'obj("cnt") 为文章内容
'''''''''''''''''''''''''''
'sample call:
'''''''''''''
' dim rs, dic
' set rs=createObject("adodb.recordset")
' rs.open "select * from ctat where aid=15783",conn
'
' set dic=fAtPgnt(rs("content"),50000,request.queryString("apid"))
' response.write dic("pgnt")&"<br/>"
' response.write dic("info")&"<br/>"
' response.write dic("cnt")&"<br/>"
' set dic=nothing
'
' rs.close
' set rs=nothing
''''''''''''''''''''''''''''''''''''''''''''''''''''''
if isNumeric(pSize)=false or len(aStr)=0 then exit function
if isNull(rId) or rId="" or isNumeric(rId)=false then rId=1 '如果分页查询ID为空则 ID为 1
dim aStrLen '取文章总长度的变量
aStrLen=len(aStr)
'智能URL字符串替换
dim rqs, url, rName
rqs=request.ServerVariables("QUERY_STRING")
rName="apid"
if rqs="" then
url="?"&rName&"="
elseif instr(rqs,rName)<>0 then
url="?"&replace(rqs,rName&"="&rId,"")&rName&"="
else
url="?"&replace(rqs,"&"&rName&"="&rId,"")&"&"&rName&"="
end if
dim tPg '定义总页数变量
tPg=int(aStrLen/-pSize)*-1
if rId<1 then rId=1 '如果分页查询ID小于1, 则为1
if cLng(rId)>cLng(tPg) then rId=tPg '如果分页查询ID大于总页数, 则为总页数
dim cPg '定义取当前页字符起始位置变量
if rId=1 then cPg=1 else cPg=pSize*(rId-1)+1 '读取文章的起始位置
dim dic '定义字典变量
set dic = createObject("scripting.dictionary")
if aStrLen<=pSize then '如果分页大小大于正文大小时, 执行以下操作
dic.add "pgnt", "" '增加页面链接到字典
'增加统计信息到字典
dic.add "info", formatNumber(pSize,0)&"字/页 "&rid&"/"&tPg&"页 共"&_
formatNumber(aStrLen,0)&"字"
dic.add "cnt", mid(aStr,1) '增加内容到字典
set fAtPgnt=dic
set dic=nothing
exit function
end if
dim i, temp, temp1
for i=1 to tPg
'如果当前查询ID=i, 则加入高亮CSS类
if strComp(rId,i,1)=0 then temp1=" class=""hl"""
temp=temp&"<a href="""&url&i&""""&temp1&">第"&i&"页</a> "
next
dic.add "pgnt", temp '增加页面链接到字典
'增加统计信息到字典
dic.add "info", formatNumber(pSize,0)&"字/页 "&rId&"/"&tPg&"页 共"&_
formatNumber(aStrLen,0)&"字"
dic.add "cnt", mid(aStr,cPg,pSize) '增加文章内容到字典
set fAtPgnt=dic
set dic=nothing
end function 'shawl.qiu code'
%>
相关文章推荐
- 服务端 JScript 记录集分页函数/对象 By shawl.qiu
- ASP VBScript 函数 之返回多个值 By shawl.qiu
- ASP 无重复数字随机函数, 数组实现, 并应用于随机显示记录集 By shawl.qiu
- ASP实现长文章自动分页的函数代码
- ASP实现长文章自动分页的函数代码
- ASP.NET长文章实现通用以及高效的分页方法
- Asp.Net实现的通用分页函数
- JScript 中 eval 实现 VBScript ExecuteGlobal 功能, 函数 fExecuteGlobal by shawl.qiu
- ASP 技巧一则之 简化创建关闭记录集对象并创建使用简单的MSSQL存储过程 By shawl.qiu
- ASP实现长文章自动分页的函数代码
- ASP 二进制与字符串互转, 另类完美解决方法, adodb.stream 实现 By shawl.qiu
- Asp.Net实现的通用分页函数
- ASP VBScript 动态包含文件, FSO 实现 By Shawl.qiu
- asp.net 中 使用 ado 的 Recordset GetString 函数 By shawl.qiu
- Javascript N层对称标记算法的实现 By shawl.qiu
- 无限级菜单结构 与 Javascript 实现算法, 类 XMenu by shawl.qiu
- ASP实现长文章手动分页的代码
- 配合ckEditor分页标签,用javascript编写分页函数,实现文章内容分页
- ASP通用分页样式函数代码
- Python Sqlite3以字典形式返回查询结果的实现方法