当前位置: 首页 > 图文教程 > 网络编程 > ASP > ASP实现长文章手动分页的代码

ASP
ASP用户登录模块的设计
ASP:一个网站空间多个域名访问
ASP教程:自己写的数据库操作类
ASP处理多关键词查询实例代码
ASP实例:幻灯片新闻代码
ASP实例:处理多关键词查询实例代码
快速掌握ASP+Access数据库的18条安全法则
快速掌握ASP连接11种数据库的常用语法
在ASP应用中如何限制同一表单被多次提交
ASP防止同时登陆的问题
关于Asp.net ajax下的异常处理
ASP生成html的新方法
ASP中的面向对象 类
ASP调用带参数存储过程的几种方式
asp实现批量录入数据的实现
用ASP调用SQL Server视图和存储过程
值得收藏的一些ASP代码
ASP 编程中 20 个非常有用的例子
每个ASP程序员必备的知识
flash结合asp制作出的显ip,版本,登陆时间,访问次数

ASP实现长文章手动分页的代码


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 90 ::
收藏到网摘: n/a

一篇文章如字数太多,则用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%>

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

 转载请注明出处: http://www.code-123.com,谢谢!