最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
ASP文章按行分页通用代码
时间:2022-07-02 23:21:22 编辑:袖梨 来源:一聚教程网
# <%
# 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")&"
"
# response.write dic("info")&"
"
# response.write dic("cnt")&"
"
# set dic=nothing
# rs.close
# set rs=nothing
#
# function fAtPgnt(aStr,pSize,rId)
# ''''''''''''''''''''''''''''''''''''''''''''''''''''''
# 'ASP 通用文章分页函数(非记录集分页), 返回多个结果, 字典实现 By shawl.qiu
# ' http://blog.111com.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")&"
"
# ' response.write dic("info")&"
"
# ' response.write dic("cnt")&"
"
# ' 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&"第"&i&"页 "
# 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'
# %>
相关文章
- 王者荣耀侦探能力大测试攻略 王者荣耀侦探能力大测试怎么过 11-22
- 无期迷途主线前瞻兑换码是什么 11-22
- 原神欧洛伦怎么培养 11-22
- 炉石传说网易云音乐联动怎么玩 11-22
- 永劫无间手游确幸转盘怎么样 11-22
- 无期迷途主线前瞻兑换码是什么 无期迷途主线前瞻直播兑换码介绍 11-22