| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1452 人关注过本帖
标题:[求助]新闻内容太长`想内页分页显示
只看楼主 加入收藏
xixifei
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2006-4-26
收藏
 问题点数:0 回复次数:13 
[求助]新闻内容太长`想内页分页显示

一篇文章的内容太长了,,,想分页显示~~~
不知道该怎么做~~
高手请指教!谢谢了~~~~

搜索更多相关主题的帖子: 新闻 一篇文章 
2006-06-10 09:36
islet
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:89
帖 子:6548
专家分:0
注 册:2005-1-28
收藏
得分:0 
动态页还是静态页

[此贴子已经被作者于2006-6-10 9:54:16编辑过]


2006-06-10 09:54
iinterest
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2006-5-27
收藏
得分:0 
我也有这个问题,我是ASP的动态页

2006-06-10 11:57
dzt0001
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:蒙面侠
威 望:5
帖 子:1281
专家分:4998
注 册:2005-10-12
收藏
得分:0 

调用请用<% call ShowArticleContent() %>
注意:rs("PaginationType")是分页种类,写入数据库.rs("Content")是内容,rs("ArticleID")是文章ID.
0 不分页
1 自动
2 手动(用[NextPage]分隔)
****************************************************

<%
'=================================================
'过程名:ShowArticleContent
'作 用:显示文章具体的内容,可以分页显示
'参 数:无
'=================================================
sub ShowArticleContent()
dim PaginationType
PaginationType=rs("PaginationType")
select case PaginationType
case 0 '不分页显示
response.write rs("Content")
case 1 '自动分页显示
call AutoPagination()
case 2 '手动分页显示
call ManualPagination()
end select
end sub

'=================================================
'过程名:ManualPagination
'作 用:采用手动分页方式显示文章具体的内容
'参 数:无
'=================================================
sub ManualPagination()
dim ArticleID,strContent,CurrentPage
dim ContentLen,MaxPerPage,pages,i
dim arrContent
ArticleID=rs("ArticleID")
strContent=rs("Content")
ContentLen=len(strContent)
CurrentPage=trim(request("ArticlePage"))
if Instr(strContent,"[NextPage]")<=0 then
response.write strContent
response.write "</p><p align='center'><font color='red'><b>[1]</b></font></p>"
else
arrContent=split(strContent,"[NextPage]")

pages=Ubound(arrContent)+1
if CurrentPage="" then
CurrentPage=1
else
CurrentPage=Cint(CurrentPage)
end if
if CurrentPage<1 then CurrentPage=1
if CurrentPage>pages then CurrentPage=pages

response.write arrContent(CurrentPage-1)

response.write "</p><p align='center'><b>"
if CurrentPage>1 then
response.write "<a href='" & strFileName & "?ArticleID=" & ArticleID & "&ArticlePage=" & CurrentPage-1 & "'>上一页</a>&nbsp;&nbsp;"
end if
for i=1 to pages
if i=CurrentPage then
response.write "<font color='red'>[" & cstr(i) & "]</font>&nbsp;"
else
response.write "<a href='" & strFileName & "?ArticleID=" & ArticleID & "&ArticlePage=" & i & "'>[" & i & "]</a>&nbsp;"
end if
next
if CurrentPage<pages then
response.write "&nbsp;<a href='" & strFileName & "?ArticleID=" & ArticleID & "&ArticlePage=" & CurrentPage+1 & "'>下一页</a>"
end if
response.write "</b></p>"

end if

end sub
'=================================================
'过程名:AutoPagination
'作 用:采用自动分页方式显示文章具体的内容
'参 数:无
'=================================================
sub AutoPagination()
dim ArticleID,strContent,CurrentPage,MaxCharPerPage
dim ContentLen,MaxPerPage,pages,i,lngBound
dim BeginPoint,EndPoint
ArticleID=rs("ArticleID")
strContent=rs("Content")
ContentLen=len(strContent)
CurrentPage=trim(request("ArticlePage"))
MaxCharPerPage=1000
if ContentLen<=MaxCharPerPage then
response.write strContent
response.write "</p><p align='center'><font color='red'><b>[1]</b></font></p>"
else
if CurrentPage="" then
CurrentPage=1
else
CurrentPage=Cint(CurrentPage)
end if
pages=ContentLen\MaxCharPerPage
if MaxCharPerPage*pages<ContentLen then
pages=pages+1
end if
lngBound=ContentLen '最大误差范围
if CurrentPage<1 then CurrentPage=1
if CurrentPage>pages then CurrentPage=pages

dim lngTemp
dim lngTemp1,lngTemp1_1,lngTemp1_2,lngTemp1_1_1,lngTemp1_1_2,lngTemp1_1_3,lngTemp1_2_1,lngTemp1_2_2,lngTemp1_2_3
dim lngTemp2,lngTemp2_1,lngTemp2_2,lngTemp2_1_1,lngTemp2_1_2,lngTemp2_2_1,lngTemp2_2_2
dim lngTemp3,lngTemp3_1,lngTemp3_2,lngTemp3_1_1,lngTemp3_1_2,lngTemp3_2_1,lngTemp3_2_2
dim lngTemp4,lngTemp4_1,lngTemp4_2,lngTemp4_1_1,lngTemp4_1_2,lngTemp4_2_1,lngTemp4_2_2
dim lngTemp5,lngTemp5_1,lngTemp5_2
dim lngTemp6,lngTemp6_1,lngTemp6_2

if CurrentPage=1 then
BeginPoint=1
else
BeginPoint=MaxCharPerPage*(CurrentPage-1)+1

lngTemp1_1_1=instr(BeginPoint,strContent,"</table>",1)
lngTemp1_1_2=instr(BeginPoint,strContent,"</TABLE>",1)
lngTemp1_1_3=instr(BeginPoint,strContent,"</Table>",1)
if lngTemp1_1_1>0 then
lngTemp1_1=lngTemp1_1_1
elseif lngTemp1_1_2>0 then
lngTemp1_1=lngTemp1_1_2
elseif lngTemp1_1_3>0 then
lngTemp1_1=lngTemp1_1_3
else
lngTemp1_1=0
end if

lngTemp1_2_1=instr(BeginPoint,strContent,"<table",1)
lngTemp1_2_2=instr(BeginPoint,strContent,"<TABLE",1)
lngTemp1_2_3=instr(BeginPoint,strContent,"<Table",1)
if lngTemp1_2_1>0 then
lngTemp1_2=lngTemp1_2_1
elseif lngTemp1_2_2>0 then
lngTemp1_2=lngTemp1_2_2
elseif lngTemp1_2_3>0 then
lngTemp1_2=lngTemp1_2_3
else
lngTemp1_2=0
end if

if lngTemp1_1=0 and lngTemp1_2=0 then
lngTemp1=BeginPoint
else
if lngTemp1_1>lngTemp1_2 then
lngtemp1=lngTemp1_2
else
lngTemp1=lngTemp1_1+8
end if
end if

lngTemp2_1_1=instr(BeginPoint,strContent,"</p>",1)
lngTemp2_1_2=instr(BeginPoint,strContent,"</P>",1)
if lngTemp2_1_1>0 then
lngTemp2_1=lngTemp2_1_1
elseif lngTemp2_1_2>0 then
lngTemp2_1=lngTemp2_1_2
else
lngTemp2_1=0
end if

lngTemp2_2_1=instr(BeginPoint,strContent,"<p",1)
lngTemp2_2_2=instr(BeginPoint,strContent,"<P",1)
if lngTemp2_2_1>0 then
lngTemp2_2=lngTemp2_2_1
elseif lngTemp2_2_2>0 then
lngTemp2_2=lngTemp2_2_2
else
lngTemp2_2=0
end if

if lngTemp2_1=0 and lngTemp2_2=0 then
lngTemp2=BeginPoint
else
if lngTemp2_1>lngTemp2_2 then
lngtemp2=lngTemp2_2
else
lngTemp2=lngTemp2_1+4
end if
end if

lngTemp3_1_1=instr(BeginPoint,strContent,"</ur>",1)
lngTemp3_1_2=instr(BeginPoint,strContent,"</UR>",1)
if lngTemp3_1_1>0 then
lngTemp3_1=lngTemp3_1_1
elseif lngTemp3_1_2>0 then
lngTemp3_1=lngTemp3_1_2
else
lngTemp3_1=0
end if

lngTemp3_2_1=instr(BeginPoint,strContent,"<ur",1)
lngTemp3_2_2=instr(BeginPoint,strContent,"<UR",1)
if lngTemp3_2_1>0 then
lngTemp3_2=lngTemp3_2_1
elseif lngTemp3_2_2>0 then
lngTemp3_2=lngTemp3_2_2
else
lngTemp3_2=0
end if

if lngTemp3_1=0 and lngTemp3_2=0 then
lngTemp3=BeginPoint
else
if lngTemp3_1>lngTemp3_2 then
lngtemp3=lngTemp3_2
else
lngTemp3=lngTemp3_1+5
end if
end if

if lngTemp1<lngTemp2 then
lngTemp=lngTemp2
else
lngTemp=lngTemp1
end if
if lngTemp<lngTemp3 then
lngTemp=lngTemp3
end if

if lngTemp>BeginPoint and lngTemp<=BeginPoint+lngBound then
BeginPoint=lngTemp
else
lngTemp4_1_1=instr(BeginPoint,strContent,"</li>",1)
lngTemp4_1_2=instr(BeginPoint,strContent,"</LI>",1)
if lngTemp4_1_1>0 then
lngTemp4_1=lngTemp4_1_1
elseif lngTemp4_1_2>0 then
lngTemp4_1=lngTemp4_1_2
else
lngTemp4_1=0
end if

lngTemp4_2_1=instr(BeginPoint,strContent,"<li",1)
lngTemp4_2_1=instr(BeginPoint,strContent,"<LI",1)
if lngTemp4_2_1>0 then
lngTemp4_2=lngTemp4_2_1
elseif lngTemp4_2_2>0 then
lngTemp4_2=lngTemp4_2_2
else
lngTemp4_2=0
end if

if lngTemp4_1=0 and lngTemp4_2=0 then
lngTemp4=BeginPoint
else
if lngTemp4_1>lngTemp4_2 then
lngtemp4=lngTemp4_2
else
lngTemp4=lngTemp4_1+5
end if
end if

if lngTemp4>BeginPoint and lngTemp4<=BeginPoint+lngBound then
BeginPoint=lngTemp4
else
lngTemp5_1=instr(BeginPoint,strContent,"<img",1)
lngTemp5_2=instr(BeginPoint,strContent,"<IMG",1)
if lngTemp5_1>0 then
lngTemp5=lngTemp5_1
elseif lngTemp5_2>0 then
lngTemp5=lngTemp5_2
else
lngTemp5=BeginPoint
end if

if lngTemp5>BeginPoint and lngTemp5<BeginPoint+lngBound then
BeginPoint=lngTemp5
else
lngTemp6_1=instr(BeginPoint,strContent,"<br>",1)
lngTemp6_2=instr(BeginPoint,strContent,"<BR>",1)
if lngTemp6_1>0 then
lngTemp6=lngTemp6_1
elseif lngTemp6_2>0 then
lngTemp6=lngTemp6_2
else
lngTemp6=0
end if

if lngTemp6>BeginPoint and lngTemp6<BeginPoint+lngBound then
BeginPoint=lngTemp6+4
end if
end if
end if
end if
end if

if CurrentPage=pages then
EndPoint=ContentLen
else
EndPoint=MaxCharPerPage*CurrentPage
if EndPoint>=ContentLen then
EndPoint=ContentLen
else
lngTemp1_1_1=instr(EndPoint,strContent,"</table>",1)
lngTemp1_1_2=instr(EndPoint,strContent,"</TABLE>",1)
lngTemp1_1_3=instr(EndPoint,strContent,"</Table>",1)
if lngTemp1_1_1>0 then
lngTemp1_1=lngTemp1_1_1
elseif lngTemp1_1_2>0 then
lngTemp1_1=lngTemp1_1_2
elseif lngTemp1_1_3>0 then
lngTemp1_1=lngTemp1_1_3
else
lngTemp1_1=0
end if

lngTemp1_2_1=instr(EndPoint,strContent,"<table",1)
lngTemp1_2_2=instr(EndPoint,strContent,"<TABLE",1)
lngTemp1_2_3=instr(EndPoint,strContent,"<Table",1)
if lngTemp1_2_1>0 then
lngTemp1_2=lngTemp1_2_1
elseif lngTemp1_2_2>0 then
lngTemp1_2=lngTemp1_2_2
elseif lngTemp1_2_3>0 then
lngTemp1_2=lngTemp1_2_3
else
lngTemp1_2=0
end if

if lngTemp1_1=0 and lngTemp1_2=0 then
lngTemp1=EndPoint
else
if lngTemp1_1>lngTemp1_2 then
lngtemp1=lngTemp1_2-1
else
lngTemp1=lngTemp1_1+7
end if
end if

lngTemp2_1_1=instr(EndPoint,strContent,"</p>",1)
lngTemp2_1_2=instr(EndPoint,strContent,"</P>",1)
if lngTemp2_1_1>0 then
lngTemp2_1=lngTemp2_1_1
elseif lngTemp2_1_2>0 then
lngTemp2_1=lngTemp2_1_2
else
lngTemp2_1=0
end if

lngTemp2_2_1=instr(EndPoint,strContent,"<p",1)
lngTemp2_2_2=instr(EndPoint,strContent,"<P",1)
if lngTemp2_2_1>0 then
lngTemp2_2=lngTemp2_2_1
elseif lngTemp2_2_2>0 then
lngTemp2_2=lngTemp2_2_2
else
lngTemp2_2=0
end if

if lngTemp2_1=0 and lngTemp2_2=0 then
lngTemp2=EndPoint
else
if lngTemp2_1>lngTemp2_2 then
lngTemp2=lngTemp2_2-1
else
lngTemp2=lngTemp2_1+3
end if
end if

lngTemp3_1_1=instr(EndPoint,strContent,"</ur>",1)
lngTemp3_1_2=instr(EndPoint,strContent,"</UR>",1)
if lngTemp3_1_1>0 then
lngTemp3_1=lngTemp3_1_1
elseif lngTemp3_1_2>0 then
lngTemp3_1=lngTemp3_1_2
else
lngTemp3_1=0
end if

lngTemp3_2_1=instr(EndPoint,strContent,"<ur",1)
lngTemp3_2_2=instr(EndPoint,strContent,"<UR",1)
if lngTemp3_2_1>0 then
lngTemp3_2=lngTemp3_2_1
elseif lngTemp3_2_2>0 then
lngTemp3_2=lngTemp3_2_2
else
lngTemp3_2=0
end if

if lngTemp3_1=0 and lngTemp3_2=0 then
lngTemp3=EndPoint
else
if lngTemp3_1>lngTemp3_2 then
lngtemp3=lngTemp3_2-1
else
lngTemp3=lngTemp3_1+4
end if
end if

if lngTemp1<lngTemp2 then
lngTemp=lngTemp2
else
lngTemp=lngTemp1
end if
if lngTemp<lngTemp3 then
lngTemp=lngTemp3
end if

if lngTemp>EndPoint and lngTemp<=EndPoint+lngBound then
EndPoint=lngTemp
else
lngTemp4_1_1=instr(EndPoint,strContent,"</li>",1)
lngTemp4_1_2=instr(EndPoint,strContent,"</LI>",1)
if lngTemp4_1_1>0 then
lngTemp4_1=lngTemp4_1_1
elseif lngTemp4_1_2>0 then
lngTemp4_1=lngTemp4_1_2
else
lngTemp4_1=0
end if

lngTemp4_2_1=instr(EndPoint,strContent,"<li",1)
lngTemp4_2_1=instr(EndPoint,strContent,"<LI",1)
if lngTemp4_2_1>0 then
lngTemp4_2=lngTemp4_2_1
elseif lngTemp4_2_2>0 then
lngTemp4_2=lngTemp4_2_2
else
lngTemp4_2=0
end if

if lngTemp4_1=0 and lngTemp4_2=0 then
lngTemp4=EndPoint
else
if lngTemp4_1>lngTemp4_2 then
lngtemp4=lngTemp4_2-1
else
lngTemp4=lngTemp4_1+4
end if
end if

if lngTemp4>EndPoint and lngTemp4<=EndPoint+lngBound then
EndPoint=lngTemp4
else
lngTemp5_1=instr(EndPoint,strContent,"<img",1)
lngTemp5_2=instr(EndPoint,strContent,"<IMG",1)
if lngTemp5_1>0 then
lngTemp5=lngTemp5_1-1
elseif lngTemp5_2>0 then
lngTemp5=lngTemp5_2-1
else
lngTemp5=EndPoint
end if

if lngTemp5>EndPoint and lngTemp5<EndPoint+lngBound then
EndPoint=lngTemp5
else
lngTemp6_1=instr(EndPoint,strContent,"<br>",1)
lngTemp6_2=instr(EndPoint,strContent,"<BR>",1)
if lngTemp6_1>0 then
lngTemp6=lngTemp6_1+3
elseif lngTemp6_2>0 then
lngTemp6=lngTemp6_2+3
else
lngTemp6=EndPoint
end if

if lngTemp6>EndPoint and lngTemp6<EndPoint+lngBound then
EndPoint=lngTemp6
end if
end if
end if
end if
end if
end if
response.write mid(strContent,BeginPoint,EndPoint-BeginPoint)

response.write "</p><p align='center'><b>"
if CurrentPage>1 then
response.write "<a href='" & strFileName & "?ArticleID=" & ArticleID & "&ArticlePage=" & CurrentPage-1 & "'>上一页</a>&nbsp;&nbsp;"
end if
for i=1 to pages
if i=CurrentPage then
response.write "<font color='red'>[" & cstr(i) & "]</font>&nbsp;"
else
response.write "<a href='" & strFileName & "?ArticleID=" & ArticleID & "&ArticlePage=" & i & "'>[" & i & "]</a>&nbsp;"
end if
next
if CurrentPage<pages then
response.write "&nbsp;<a href='" & strFileName & "?ArticleID=" & ArticleID & "&ArticlePage=" & CurrentPage+1 & "'>下一页</a>"
end if
response.write "</b></p>"
end if

end sub
%>

[此贴子已经被作者于2006-6-10 14:50:13编辑过]


----我怎能在别人的苦难面前转过脸去----
2006-06-10 14:48
craft001wen
Rank: 2
等 级:论坛游民
帖 子:242
专家分:62
注 册:2006-5-4
收藏
得分:0 
强啊,这么多代码,看看都看晕了

2006-06-10 15:21
yzwt2004
Rank: 1
等 级:新手上路
帖 子:472
专家分:0
注 册:2006-1-18
收藏
得分:0 


想学 .Net 了
2006-06-12 11:00
hangxj
Rank: 6Rank: 6
等 级:贵宾
威 望:29
帖 子:2045
专家分:0
注 册:2006-4-10
收藏
得分:0 

http://www./
2006-06-12 11:25
dangdang_198
Rank: 1
等 级:新手上路
帖 子:85
专家分:0
注 册:2006-4-17
收藏
得分:0 

欢迎加入技术群5725994
2006-06-12 13:38
271391233
Rank: 1
等 级:新手上路
帖 子:174
专家分:0
注 册:2005-2-24
收藏
得分:0 
晕晕的~~~~~~~~~~!

坚持就是胜利>>静心,静思
2006-06-13 00:31
xixifei
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2006-4-26
收藏
得分:0 

晕晕的。。。还是没做出来?~~~~~

再试试~~~~

2006-06-13 15:04
快速回复:[求助]新闻内容太长`想内页分页显示
数据加载中...
 
   



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

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