做一个文章分页页面

banner90 2003-10-20 09:25:08
我想做一个文章分页,就是能够限定一边文章显示的字数,然后实现分页,请问有没有相应的文档?
...全文
93 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
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
banner90 2003-10-21
  • 打赏
  • 举报
回复
这样不是很好把,在添加文章得时候分页,我想在查看文章得页面分页
jz_bnx 2003-10-20
  • 打赏
  • 举报
回复
超长字符的智能分页-支持HTML。
大洲 发表于 6/6/2002 4:01:25 PM Joy ASP ←返回版面 [快速返回]

大概在九九年做游戏网站的时候,就对文章的发布感到麻烦,不过那会儿玩ASP不精。只是将就用着。在遇到长文件 10000 字时网页就是一大片长了。

去年,做一个通用的文章与新闻管理系统时,曾写了一段代码,用来分离。现在贴出来。

要说明的是:

我的文章 录入界面是基于WEB的HEMLEDITOR,就像这里的ABC代码差不多。所以实际提交的是HTML格式的文 本。

对HTML做了相应的处理,不会由HTML代码中切开。

这里另一位兄弟曾发表过一个,原理一样,不过我没仔细看过,不知有啥不同。


代码如下:
--------------------------------------
'Request Form Item
I_Forder = Request.Form ("I_Folder")
I_Topic = Request.Form ("I_Topic")
I_Title = htmlencode(Request.Form ("I_Title"))
I_Body = Request.Form ("body")
I_Source = Request.Form ("I_Source")
I_Keyword= htmlencode(Request.Form ("I_Keyword"))
I_ISHOT = request.form("ishot")
if i_ishot = "" then i_ishot="N"
i_ispic = request.form("ispic")
if i_ispic = "" then i_ispic ="N"
i_pic = request.form("InsertImage")
i_body = replace(i_body,"contentEditable=true","contentEditable=false")

'Check Input
'......

'Get Pages ,B = Body
B_Len = Len(I_Body)
B_Pages = 1
'T = Temp
T_Loop = true

Do While T_Loop '这里loop多次,每4000分一页,算出页码并加入库。
If B_Len > 4000 then
N_Body = Left(I_Body,4000) 'N = New
'If "<P" in N_Body,Else ">" in N_Body
If Instrrev(N_Body,"<P") > 0 and (Len(N_Body) - Instrrev(N_Body,"<P"))< 400 then
N_Body = Left(N_Body,InstrRev(N_Body,"<P")-1)
else if Instrrev(N_Body,"  ") > 0 and (Len(N_Body) - Instrrev(N_Body,"  "))< 400 then
N_Body = Left(N_Body,InstrRev(N_Body,"  ")-1)
Else If Instrrev(N_Body,"。") > 0 and (Len(N_Body) - Instrrev(N_Body,"。"))< 400 then
N_Body = Left(N_Body,InstrRev(N_Body,"。"))
Else If Instrrev(N_Body,";") > 0 and (Len(N_Body) - Instrrev(N_Body,";"))< 400 then
N_Body = Left(N_Body,InstrRev(N_Body,";"))
else if Instrrev(N_Body,",") > 0 and (Len(N_Body) - Instrrev(N_Body,","))< 400 then
N_Body = Left(N_Body,InstrRev(N_Body,","))
else if Instrrev(N_Body,".") > 0 and (Len(N_Body) - Instrrev(N_Body,"."))< 400 then
N_Body = Left(N_Body,InstrRev(N_Body,"."))
end if
end if
End If
End If
end if
End if

N_Len = Len(N_Body)
I_Body = Mid(I_Body,N_Len+1)
B_Len = Len(I_Body)

Else
N_Body = I_Body
T_Loop = false
End If


'Add to database
Exec_prc_Content_Ins I_Forder,I_Topic,I_Title,I_Source,N_Body,i_ispic,i_pic,i_ishot,I_Keyword,B_Pages

'这里一个function,你可以自己处理,反正结果有两个,一个是body,一个是b_pages,就是页码。


B_Pages = B_Pages + 1

Loop


%>

<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页 1</title>
<link rel="stylesheet" type="text/css" href="../CSS/default.css">
</head>

<body>

<div align="center">
<center>

<table border=1 width="300" height="128" bordercolor="#000000" cellspacing="0" cellpadding="0" style="border-collapse: collapse"><tr>
<td bgcolor="#DEDBD6" height="31">
录入成功</td></tr><tr><td height="96">
<p align="center">此文章共分<%=B_Pages-1%>页
</td></tr></table>


</center>
</div>
<script>
top.main_top.location.reload();
</script>

</body>
banner90 2003-10-20
  • 打赏
  • 举报
回复
就是说,一编文章,我只希望他显示100个字符,超过100个字符就到下一页,
zhanghao5188 2003-10-20
  • 打赏
  • 举报
回复
???讲明白一些?

28,390

社区成员

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

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