| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 584 人关注过本帖
标题:分页问题
只看楼主 加入收藏
五岳狂人
Rank: 1
等 级:新手上路
帖 子:168
专家分:0
注 册:2006-3-24
收藏
 问题点数:0 回复次数:4 
分页问题
比如我有一篇很长的文字,我想分页显示怎么写代码啊
搜索更多相关主题的帖子: 文字 代码 
2008-03-20 22:29
luo123
Rank: 1
等 级:新手上路
威 望:2
帖 子:324
专家分:0
注 册:2007-4-13
收藏
得分:0 
<title>蓝鹰留言本</title>
</head>

<body>


 <p align="center"><a href="/index.asp">蓝鹰留言本</a></p>
 <p align="right">
 <%
   
   if Session("Sname")<>"" then
    response.write("<a href="/"logout.asp"">退出管理</a>")
   else
    response.write("<a href="/"login.asp"">管理登陆</a>")
   end if
   %></p>

 <table width="780"  border="1" align="center" cellspacing="0" >
   <tr>
     <td width="100" height="20"><div align="center">留言人</div></td>
     <td width="200"><div align="center">留言标题</div></td>
     <td width="380"><div align="center">留言内容</div></td>
     <td width="100"><div align="center">时间</div></td>
   </tr>
   
<% Language="VBScript"

dim connstr
dim totalPut
dim CurrentPage
dim TotalPages
dim i,j
dim sql

on error resume next

'定义每页文章显示数
const MaxPerPage=10
if not isempty(request("page")) then
currentPage=cint(request("page"))
else
currentPage=1
end if

'数库表guesttext
sql="select * from guesttext order by id desc"
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,1
mb_demo=replace(rs("mb_demo"),chr(10)+chr(13),"<br>")
if rs.eof and rs.bof then
response.write "<p align='center'> 还没有任何留言</p>"
else totalPut=rs.recordcount '数据库中留言数totalput
if currentpage<1 then
currentpage=1
end if
'统计总页数currentpage
if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else currentpage= totalPut \ MaxPerPage + 1
end if
end if
if currentPage=1 then
showpage totalput,MaxPerPage,"index.asp"
showContent
showpage totalput,MaxPerPage,"index.asp"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showpage totalput,MaxPerPage,"index.asp"
showContent
showpage totalput,MaxPerPage,"index.asp"
else currentPage=1
showpage totalput,MaxPerPage,"index.asp"
showContent
showpage totalput,MaxPerPage,"index.asp"
end if
end if
rs.close
end if
set rs=nothing
conn.close
set conn=nothing
sub showContent
dim i
i=0
do while not rs.eof
%>

 
  <table width="780"  border="1" align="center" cellspacing="0">

   <tr>
     <td width="100" height="80"><% =rs("guest") %></td>
     <td width="200" height="80"><% =rs("title") %></td>
     <td width="380" height="80"><% =rs("text") %></td>
     <td width="100" height="80"><% =rs("time") %></td>
   </tr>
   <tr bgcolor="#9999FF">
     <td height="20" colspan="4"><A href="send.asp?ID=<%=rs("id")%>">回复</a> |<a href="del.asp?ID=<% =RS("ID")%>">删除</A></td>
   </tr>
</table>

 

<% '当显示记录大于maxperpage时结束这页
i=i+1
if i>=MaxPerPage then exit do
rs.movenext
loop
end sub
function showpage(totalnumber,maxperpage,filename)
'求出当每页5条记录时总共的页数
dim n
if totalnumber mod maxperpage=0 then
n= totalnumber \ maxperpage
else n= totalnumber \ maxperpage+1
end if
response.write "<form method=Post action="&filename&">"
response.write "<p align='center'><font color='#000080'>>>分页</font> "
'显示页数链接的条件
if CurrentPage<2 then
response.write "<font color='#000080'>首页 上一页</font> "
else response.write "<a href="&filename&"?page=1&>首页</a> "
response.write "<a href="&filename&"?page="&CurrentPage-1&">上一页</a> "
end if
if n-currentpage<1 then
response.write "<font color='#000080'>下一页 尾页</font>"
else response.write "<a href="&filename&"?page="&(CurrentPage+1)
response.write ">下一页</a> <a href="&filename&"?page="&n&">尾页</a>"
end if
response.write "<font color='#000080'> 页次:</font><strong><font color=red>"&CurrentPage&"</font><font color='#000080'>/"&n&"</strong>页</font>"
response.write "<font color='#000080'> 共<b>"&totalnumber&"</b>笔记录<b>&nbsp;"&maxperpage&"</b>笔记录/页</font>"
response.write "<font color='#000080'>转到:</font><input class=smallInput type='text' name='page' size=4 maxlength=10 value="&Currentpage&">"
response.write "<input class=buttonface type='submit' value=' Goto ' name='cndok'></span></p></form>"
end function
%>

[url=http://www..cn]电子编程[/url]
2008-03-20 23:30
五岳狂人
Rank: 1
等 级:新手上路
帖 子:168
专家分:0
注 册:2006-3-24
收藏
得分:0 
不是这个意思了
我有一篇文章,而且很长,我想分成几页,一页一页的看
不是有几条记录几条记录的看啊

2008-03-21 09:32
madpbpl
Rank: 4
等 级:贵宾
威 望:11
帖 子:2876
专家分:244
注 册:2007-4-5
收藏
得分:0 
提供一个思路
文章设置一个特别符号比如"[page]"符号,读取文章的时候 以[page]为分割符 分割(arr=split(str,"[page]"))
2008-03-21 10:26
五岳狂人
Rank: 1
等 级:新手上路
帖 子:168
专家分:0
注 册:2006-3-24
收藏
得分:0 
有没有简单一点的代码啊?

2008-03-21 11:20
快速回复:分页问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011602 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved