首页 | 站长免费中心 | 新手上路 | 网站运营 | 网页制作 | 图片设计 | 动画设计 | 网页编程 | 网页特效 | 本站专题 | 虚拟主机 | 域名注册 | 网站建设 | 程序下载
       免费空间资源 | 新闻咨询 | 免费域名 | 免费网盘 | 网站推广 | 网站策划 | 建站经验 | 网站优化 | 网页代码 | 源码下载 | 音乐小偷 | 网络赚钱 | 论坛交流
网站建设
网站建设
虚拟主机
虚拟主机
域名注册
域名注册
711网络首页
站长工具
站长工具
网站源码
网站源码
站长论坛
站长论坛

 711网络 网页编程ASP代码

页内分页函数(按字数分)

来源: 互联网    日期:2007-1-13 15:10:56
 

    根据字数对文章进行页内分页 [转自:711网络工作室 http://www.tc711.com]

    <%
    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 "&table&" " 'table 表明
    rs.open sql,conn,1,1
    ami_content=rs(""&content&"") '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 "<br>"
    for i=1 to ami_pageCount+1 '页数展示
    response.Write "[<a href="&action&"?"&temp&"wordPage="&i&">"&i&"</a>]"
    next
    response.Write "[<a href="&action&"?"&temp&"wordPage=all>单页显示</a>]"
    rs.close
    set rs=nothing
    end function
    %>  [转自:711网络工作室 http://www.tc711.com]

    调用函数的代码是

<%call word_pagination("amily","content",600)%>

    大家也注意到了咯 `````

function word_pagination(table,content,wordcount)
    table 为表明
    content 为字段名
    (添加的时候 注意加引号咯)
    wordcount 为字数

    嘿嘿 今天先到这里把
    程序还有一些不好的地方 比如分页的时候 会直接断句
    这个下次 再来咯

     



更多的页内分页函数(按字数分)请到论坛查看: http://BBS.TC711.COM



【 双击滚屏 】 【 评论 】 【 收藏 】 【 打印 】 【 关闭 】 来源: 互联网    日期:2007-1-13 15:10:56   

发 表 评 论
查看评论

  您的大名:
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款
认证编码: 刷新验证码
点评内容: 字数0
  精品推荐  
  本月推荐  
  友情赞助  

关于我们 | 联系我们 | 广告投放 | 留言反馈 | 免费程序 | 虚拟主机 | 网站建设 |  网站推广 |  google_sitemap baidu_sitemap RSS订阅
本站所有资源均来自互联网,如有侵犯您的版权或其他问题,请通知管理员,我们会在最短的时间回复您
Copyright © 2005-2015 Tc711.Com All Rights Reserved 版权所有·711网络   蜀ICP备05021915号
110网监备案 信息产业备案 不良信息举报