新闻发布系统怎么实现自动分页功能?

songwin 2003-02-07 02:45:32
新闻发布系统怎么实现自动分页功能?

大家帮帮忙,谢谢。

给个这样的程序、思路也好。
...全文
88 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
「已注销」 2003-02-07
  • 打赏
  • 举报
回复
有几个实现方法,

一个是在添加信息的时候插入相关的标记,比如:

<!--Nextpage-->

这样在读取信息的时候读到这里时开始分页.

现成程序我有,不过不在这电脑上,如果你要,改天我发给你.看看.
songwin 2003-02-07
  • 打赏
  • 举报
回复
谢谢大家热心
对不起,我没有表达清楚我的意思。我这里的“分页”是指,比如我 发布一条新闻,但是新闻内容很长,可以分几页显示。说的不清楚,看看下面这个就明白些

http://www.pconline.com.cn/pingce/baogao/digital/10212/121957.html
ckxp 2003-02-07
  • 打赏
  • 举报
回复
给你这样一个分页完全代码,你照着改改就行了,用着非常方便。
========================================
<%
Const MaxPerPage=17
dim totalPut
dim CurrentPage
dim TotalPages
dim i,j
dim sql
dim rs

if Not isempty(request("page")) then
currentPage=Cint(request("page"))
else
currentPage=1
end if

Set rs= Server.CreateObject("adodb.recordset")
sql="Select * from news order by publishdate desc"
rs.open sql,conn,1,1
if err.number<>0 then
response.write "数据库中无数据"
end if

if rs.eof And rs.bof then
Response.Write "<p align='center' class='contents'> 对不起,暂时没有任何新闻!</p>"
else
totalPut=rs.recordcount

if currentpage<1 then
currentpage=1
end if

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
showContent
showpage totalput,MaxPerPage,"allnews.asp"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
showpage totalput,MaxPerPage,"allnews.asp"
else
currentPage=1
showContent
showpage totalput,MaxPerPage,"allnews.asp"
end if
end if
rs.close
end if

Set rs=Nothing
conn.close
Set conn=nothing

sub showContent
dim i
i=0

%>
<table width="96%" border="0" align="center" cellspacing="4" cellpadding="0">
<%Do While Not rs.eof%>
<tr>
<td width="90%" height="20" class="contents"><A href="javascript:openwin(<%=rs("id")%>)">□
<%=rs("title")%></a></td>
<td height="20" nowrap class="contents"><%=formatdatetime(rs("publishdate"),yyyy-mm-dd)%></td>
</tr>
<%
i=i+1
if i>=MaxPerPage then Exit Do
rs.movenext
Loop
%>
</table>
<%
End Sub

Function showpage(totalnumber,maxperpage,filename)
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' class='contents'> "
If CurrentPage<2 Then
Response.Write "<font class='contents'>首页 上一页</font> "
Else
Response.Write "<a href="&filename&"?page=1 class='contents'>首页</a> "
Response.Write "<a href="&filename&"?page="¤tPage-1&" class='contents'>上一页</a> "
End If

If n-currentpage<1 Then
Response.Write "<font class='contents'>下一页 尾页</font>"
Else
Response.Write "<a href="&filename&"?page="&(CurrentPage+1)&" class='contents'>"
Response.Write "下一页</a> <a href="&filename&"?page="&n&" class='contents'>尾页</a>"
End If
Response.Write "<font class='contents'> 页次:</font><font class='contents'>"¤tPage&"</font><font class='contents'>/"&n&"页</font> "
Response.Write "<font class='contents'> 共"&totalnumber&"条记录 "&maxperpage&"条记录/页</font> "
Response.Write "<font class='contents'>转到:</font><input type='text' name='page' size=4 maxlength=10 class=smallInput value="¤tpage&">"
Response.Write "<input type='submit' class='contents' value='转到' name='cndok'></form>"
End Function
%>
zhpfaff 2003-02-07
  • 打赏
  • 举报
回复
你想怎么分页?
用ASP的分页功能不就行了,按你的条件Select ,然后用Recordset的分页属性就可以了
RSCount=RS.RecordCount
pgsz=20
IF RSCount> 0 Then
i=1
RS.PageSize=pgsz ‘每页显示的记录
Total=Int(RSCount/pgsz*-1)*-1 '页数
PageNo=Request.QueryString("page") 当前页

RS.AbsolutePage = PageNo
position=RS.PageSize*PageNo
pagebegin=position-RS.PageSize+1
if position <RS.RecordCount then
pagend=position
else
pagend= RSCount
end if
RowCount=RS.Pagesize
Do while NOT RS.EOF and RowCount>0
。。。。。
RowCount=RowCount-1
RS.MoveNext
loop
end if

28,408

社区成员

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

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