ASP 按数字分页

<% 
function word_pagination(table,content,wordcount) 
dim wordPage,action,ami_wordCount,ami_wordSum,ami_wordMod,ami_pageCount,query, ami, ly, temp
wordPage=request.QueryString("wordPage") '获得wordPage
action = "http://" & Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("SCRIPT_NAME")
'获得网页地址
query = Split(Request.ServerVariables("QUERY_STRING"), "&") '获得参数,并分解参数
For Each ly In query 
ami = Split(ly, "=")'对参数进行分析
If StrComp(ami(0), "wordPage",vbTextCompare) <> 0 Then '若参数排除本函数生成的参数
temp = temp & ami(0) & "=" & ami(1) & "&" '生成参数列表(ami=1)
End If
next
set rs=server.CreateObject("adodb.recordset")
sql="select * from news_t where n_id=20 " 'table 表明
rs.open sql,conn,1,1
ami_content=rs("n_body") 'content 进行分页内容的字段名
ami_wordCount=wordCount '每页字数
ami_wordSum=len(ami_content) '计算总字数
ami_wordMod=ami_wordSum mod ami_wordCount '计算最后一页字数
ami_pageCount=int(ami_wordSum/ami_wordCount)'计算页数,总页数=ami_pagecount+1
if wordPage="all" then '单页显示值
wordPage=0
end if
if isEmpty(wordPage)=true then '分析如wordPage无参数传来,wordpage则为首页
wordPage=1
else 
wordPage=int(wordPage) '否则等于参数值,并int
end if 
if wordPage=0 then '判断参数的几种类型,并根据参数的类型进行分页
ami_content=ami_content
elseif wordPage<ami_pageCount+1 and wordPage>0 then
ami_content=mid(ami_content,ami_wordCount*(wordPage-1)+1,ami_wordCount)
elseif wordPage=ami_pageCount+1 then
ami_content=mid(ami_content,ami_wordCount*ami_pageCount+1,ami_wordMod)
elseif wordPage>ami_pageCount+1 and wordPage<0 then
ami_content="非法参数,请返回"
end if
response.Write ami_content
response.Write "
<div align=right style='padding-right:30px'>"
for i=1 to ami_pageCount+1 '页数展示
response.Write "第[<a href="&action&"?"&temp&"wordPage="&i&" style=""color:#0000ff"">"&i&"</a>]页&nbsp;"
next
response.Write "[<a href="&action&"?"&temp&"wordPage=all>全部显示</a>]&nbsp;"
response.Write "[<a href=""javascript:window.print()"">打印此页</a>]&nbsp;"
response.Write "[<a href=""javascript:window.close()"">关闭窗口</a>]"
response.Write "</div>"
set rs=nothing
end function
 %>
 
 
<%call word_pagination("amily","content",10000)%> 

转载与百度.

转载于:https://www.cnblogs.com/shenyue/archive/2008/03/14/1104850.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值