求:文章分页

xiaotu2000 2003-12-19 11:38:33

文章过长而是页面变形
先要求文章分页代码
以 第一页 前一页 下一页 最后一页
或者 1 2 3 4
分页!
谢谢
...全文
29 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
ymeik 2004-03-08
  • 打赏
  • 举报
回复
关注!
lawdoor 2004-03-08
  • 打赏
  • 举报
回复
利用统计文章字数,然后达到一定字数就截断输出,但是分页的内容就会在莫名其妙的地方截断,不是很友好。
很简单,在要截断的地方附近找下面的符号:
;’”?。!;'".!
如果后面存在<p>或<br>就分页。主要是要研究文章的格式。
<%
if Request.ServerVariables("Content_Length") > 0 then
content = Request.Form("textarea1")

PageLength = 1000 '每页字数
CLength = Len(content)
PageCount = Int(Clength/PageLength) + 1 '计算页数

dim PageArray
redim PageArray(PageCount)

Seperator = Array(chr(13),chr(10),"。","!","?",";",",","”","’") '分隔符

PageArray(0) = 0
Pos = 0
for j=0 to ubound(Seperator)
Pos = instr(PageArray(i)+900,content,Seperator(j)) 'PageArray(i)+900 附近位置是100字,1-999可调
while Pos > 0 and Pos < (i+1)*PageLength and Pos > i*PageLength
PageArray(i) = Pos
Pos = instr(Pos+PageLength,content,Seperator(j))
wend

if PageArray(i) > 0 then
Response.Write "0:i¦ "&PageArray(i)&"<br>"&j&":j"&Seperator(j)&"<br>"
j = j + ubound(Seperator) + 1
end if
next

for i=1 to PageCount-1
PageArray(i) = 0
Pos = 0
for j=0 to ubound(Seperator)
Pos = instr(PageArray(i-1)+950,content,Seperator(j))
while Pos > 0 and Pos < (i+1)*PageLength and Pos > i*PageLength
PageArray(i) = Pos
Pos = instr(Pos+PageLength,content,Seperator(j))
wend

if PageArray(i) > 0 then
Response.Write i&":i¦ "&PageArray(i)&"<br>"&j&":j"&Seperator(j)&"<br>"
j = j + ubound(Seperator) + 1
end if
next
next

output = mid(content,1,PageArray(0))
output = replace(output,chr(13),"<br>")
Response.Write "<br><br>第1段<br>"
Response.Write output

for i=1 to PageCount-2
output = mid(content,PageArray(i-1)+1,PageArray(i)-PageArray(i-1))
output = replace(output,chr(13),"<br>")
Response.Write "<br><br>第"&i+1&"段<br>"
Response.Write output
next

'最后一段的输出就没写了

else
%>
<FORM action="" method=POST id=form1 name=form1>
<TEXTAREA rows=70 cols=120 id=textarea1 name=textarea1>
</TEXTAREA>
<INPUT type="submit" value="Submit" id=submit1 name=submit1>
</FORM>
<%end if%>
eyun 2004-03-08
  • 打赏
  • 举报
回复
给你个例子

<%
page=request.QueryString("page")
if page="" then
page=1
end if
Set conn_inc=Server.CreateObject("ADODB.Connection")
Connstr="DBQ="+server.mappath("a.mdb")+";DRIVER={Microsoft Access Driver (*.mdb)};"
Conn_inc.Open connstr
sql=" select * from a where a='5' "
set rs=conn_inc.execute(sql)
a=rs("b")
lo=len(a)
num=cint(lo/50)+1
response.Write("文章共"&lo&"个字,分"&num&"页显示,每页50个字<br>")

if lo>50 then
temp=mid(a,50*(page-1)+1,50)
response.Write(temp)

response.Write(num)
response.Write("<br>")
for i=1 to num%>
<a href="fy.asp?page=<%= i %>"><%= i %></a>
<%
next
else
response.Write(a)
end if
%>

可以参考:
http://www.eyun.org/friend/fy.asp
lsaturn 2003-12-24
  • 打赏
  • 举报
回复
是文章分页
看错了!
yanqindarling 2003-12-24
  • 打赏
  • 举报
回复
up!!!
ib915 2003-12-20
  • 打赏
  • 举报
回复
www.google.com/www.baidu.com 搜索有这样的文章
对一篇很长的文章做到完美的分页输出
lsaturn 2003-12-19
  • 打赏
  • 举报
回复
注意CursorType = 3 or 2
<a href="xxx.asp?page=1>1</a>
<a href="xxx.asp?page=2>2</a>
lsaturn 2003-12-19
  • 打赏
  • 举报
回复
注意CursorType = 3 or 2
<a href="xxx.asp?page=1>1</a>
<a href="xxx.asp?page=2>2</a>
lsaturn 2003-12-19
  • 打赏
  • 举报
回复
Dim PageSize,PageCount,CurPage,i
PageSize = 15
CurPage = Trim(Request.QueryString("page"))

If CurPage = "" Then
CurPage = 1
Else
CurPage = CInt(CurPage)
End If



set MM_rsClient = Server.CreateObject("ADODB.Recordset")
With MM_rsClient
.ActiveConnection = MM_conn1_STRING
.Source = "SELECT * FROM dbo.T_Client"
.CursorType = 3
.CursorLocation = 2
.LockType = 3
.Open
.PageSize = PageSize
PageCount = .PageCount
If .PageCount < CurPage Then
.AbsolutePage = .PageCount
Else
.AbsolutePage = CurPage
End If
End With

28,407

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧