zoukankan      html  css  js  c++  java
  • ASP实现长文章手动分页的代码

    一篇文章如字数太多,则用1,2,3....  分成多页,便于用户浏览。

    <% 
    set recordset1=server.createobject("adodb.recordset") 
    exec="SELECT * FROM news  where id="&id 
    recordset1.Open exec,conn,1,1 
    %>
     <table width="85%" border="0" align="center" cellpadding="3" cellspacing="0">
              <tr>  <td >
    .......

    <%
    If Request("page")="" Then
    pageNum=0
    Else
    pageNum=Request("page")
    End if
    Content=Replace(recordset1("content"),"|||","|||")
    ContentStr=split(Content,"|||")
    For i=pageNum to pageNum
    %>
    <%=ContentStr(i)%> 
    <% Next %>
                </td>
              </tr>
     <%if ubound(ContentStr)>=1 then%>
              <tr> 
                <td height="30" >本文共分 
    <%
    For p = 0 to ubound(ContentStr)
    if p+1= Request("page")+1 then
    a="<font color=red>"
    aa="</font>"
    else
    a=""
    aa=""
    end if
    %>
                  <a href="detail.asp?ID=<%=request("ID")%>&page=<%=p%>"><%=a%><%=p+1%><%=aa%></a> 
                  <% Next %>
                  页 </td>
              </tr>
              <%end if%>

    添加文章时,在想分页的地方,加入分割符 ||| 即可。

  • 相关阅读:
    linux下安装redis 3.2.1
    redis 登入,检查
    断写了一年的博客~~
    前端面试的感想
    http和web缓存
    http请求报文和响应报文(2)
    http请求报头和响应报头(1)
    网络编程(一)
    防恶意解析,禁止用IP访问网站的Apache设置 修改 httpd.conf 实现
    About English Web Site Font
  • 原文地址:https://www.cnblogs.com/tonybinlj/p/1506692.html
Copyright © 2011-2022 走看看