| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1900 人关注过本帖
标题:我很想了解静态分页的原理
只看楼主 加入收藏
盖茨他爹
Rank: 6Rank: 6
等 级:贵宾
威 望:28
帖 子:5255
专家分:0
注 册:2005-5-3
收藏
得分:0 
真实的静态分页也不难无非就是用循环和判断语句来实现,楼主很早就一直在讨论这个问题,一直没有跳出这个圈子:
1、静态分页不象recordset对象的pagesize等属性设置一下就自动分出来,没有这么简单,要靠自己用程序实现。
2、静态分页的列表页和内容页没有任何联系(除了列表页的连接指向内容页),我们浏览的时候感觉一个列表页每个页面包含多少内容,其实内容页根本不是包含在列表页中的,只要把连接做过去就可以了。不知道能不能明白我的意思。
2005-11-05 15:07
islet
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:89
帖 子:6548
专家分:0
注 册:2005-1-28
收藏
得分:0 
正常靠循环
示意:
sub fos1(str,page)
……''fso生成
end sub
str=初始代码
do while not rs.eof
……
str=str&……
i=i+1
if i mod 10 =0 then
j=j+1
str=str&结束代码
call fso1(str,"index_"&j&".html")
str=初始代码
end if
rs.movenext
loop

反向没用过 估计要检查记录数 盼多出最后一页的内容 再生成
2005-11-05 15:22
caiyakang
Rank: 2
等 级:新手上路
威 望:5
帖 子:2111
专家分:0
注 册:2005-3-24
收藏
得分:0 

生成分页,
是不是每个页面都是重新从数据库中读取数据,然后有用FSO+模板,一页面一页面的生成.
最后分页自已根据生成的结果来进得显示分页总数.等等,
不知道是不是这样子的.


中国人的财富网:http://www..cn/
2005-11-05 18:58
caiyakang
Rank: 2
等 级:新手上路
威 望:5
帖 子:2111
专家分:0
注 册:2005-3-24
收藏
得分:0 
<!--#include file="articleconn.asp"-->
<%
IF Session("KEY")<>"super"THEN
response.redirect "mymanage.asp"
response.end
END IF
TypeItem=request("ItemName")
set rs=server.CreateObject("Adodb.Recordset")
sql="select * from type where typename='"&TypeItem&"'"
rs.open sql,conn,1,1
Type_Fold=rs("typename")
Type_Name=rs("type")
Type_index=rs("TypeIndex")
if rs.eof then
Response.Write("没有此栏目")
else
set rs_up=server.CreateObject("Adodb.recordset")
sql_up="select * from type"
rs_up.open sql_up,conn,1,1
i=1
do while not rs_up.eof
Menu=Menu&"<a href=../"&rs_up("typename")&"/"&rs_up("typeindex")&">"&rs_up("type")&"</a><font color='#0099FF'><b>—</b></font>"
i=i+1
rs_up.movenext
loop
rs.close
rs_up.close
TypeContent_sql="select * from article where typename='"&Type_Name&"'"
rs.open TypeContent_sql,conn,1,1
if rs.eof then
TypeContent=TypeContent&"此栏目暂时没有任何内容"
else
const MaxPerPage=3
rs.pagesize=MaxPerPage
CurrentPage=request("PageNo")
if CurrentPage="" then
CurrentPage=1
elseif CurrentPage<1 then
CurrentPage=1
else
CurrentPage=clng(CurrentPage)
if CurrentPage>rs.pagecount then
CurrentPage=rs.pagecount
end if
end if
if not isnumeric(CurrentPage) then
CurrentPage=1
end if
Totalput=rs.recordcount
if Totalput mod MaxPerPage=0 then
n=Totalput\MaxPerPage
else
n=Totalput\MaxPerPage+1
end if
if n=0 then
n=1
end if
rs.move(CurrentPage-1)*MaxPerPage
TypeContent=TypeContent&"<table width='100%' border='0' cellspacing='0' cellpadding='0'>"
TypeContent=TypeContent&"<tr bgcolor='#009933'><td width='65%'>标题:</td>"
TypeContent=TypeContent&"<td width='25%' align='center'>日期:</td>"
TypeContent=TypeContent&"<td width='10%' align='center'>点击:</td></tr>"
TypeContent=TypeContent&""
for i=1 to rs.pagesize
if rs.eof then
Exit for
end if
TypeContent=TypeContent&"<tr><td><a href=../"&rs("path")&"/"&rs("N_fname")&">"&rs("title")&"</a></td>"
TypeContent=TypeContent&"<td align='center'>"&rs("dateandtime")&"</td>"
TypeContent=TypeContent&"<td align='center'><script language='javascript' src='../hits.asp?newsid="&rs("newsid")&"'></script></td></tr>"
rs.movenext
next
rs.close
set rs=nothing
conn.close
set conn=nothing
TypeContent=TypeContent&"</table>"
PageLoad=PageLoad&"<form name='form1'>"
PageLoad=PageLoad&"&nbsp;页数<font color=red><b>"&currentpage&"</b></font>/"&n&"&nbsp;"
k=currentpage
if k<>1 then
PageLoad=PageLoad&"<In"&"dex.html>首页</a>&nbsp;"
if k=2 then
PageLoad=PageLoad&"<a href=In"&"dex.html>上一页</a>&nbsp;"
else
PageLoad=PageLoad&"<a href="&Type_Fold&"_"&k-1&".htm>上一页</a>&nbsp;"
end if
else
PageLoad=PageLoad&"首页&nbsp;上一页&nbsp;"
end if
if k<>n then
PageLoad=PageLoad&"<a href="&Type_Fold&"_"&k+1&".htm>下一页</a>&nbsp;"
PageLoad=PageLoad&"<a href="&Type_Fold&"_"&n&".htm>尾页</a>&nbsp;"
else
PageLoad=PageLoad&"下一页&nbsp;尾页&nbsp;"
end if
PageLoad=PageLoad&"共有<font color=blue><b>"&totalput&"</b></font>篇文章"
PageLoad=PageLoad&"<select name='menu1' onChange=MM_jumpMenu('parent',this,0)>"
for i=1 to n
if i=1 then
PageLoad=PageLoad&"<option value=In"&"dex.html"
else
PageLoad=PageLoad&"<option value="&Type_Fold&"_"&i&".htm "
end if
if cint(i)=cint(currentpage) then PageLoad=PageLoad& " selected"
PageLoad=PageLoad&">第"&i&"页</option>"
next
PageLoad=PageLoad&"</select></form>"
end if
Set fso = Server.CreateObject("Scripting.FileSystemObject")
set type_d = fso.opentextfile(server.mappath("Admin/more.html"),1,True)
pencat= type_d.ReadAll
pencat=replace(pencat,"$Menu$",Menu)
pencat=replace(pencat,"$TypeContent$",TypeContent)
pencat=replace(pencat,"$PageLoad$",PageLoad)
pencat=replace(pencat,"$TITLE$",Type_Name)
if CurrentPage<2 then
Set type_x = fso.CreateTextFile(server.mappath(Type_Fold&"/In"&"dex.html"),true)
else
Set type_x = fso.CreateTextFile(server.mappath(Type_Fold&"/"&Type_Fold&"_"&currentPage&".htm"),true)
end if
type_x.WriteLine (pencat)
set fso = nothing
type_d.close
type_x.close
response.write "<br>已生成/要生成分类:<font color=#FF0000>"&currentPage&"</font>/<font color=#FF0000><b>"&n&"</b></font>个,"
if n=<currentPage then
response.write "操作完成!"
response.Write("<a href='#' onclick=history.back()>返回</a>")
response.end
else
response.write "<br>已生成/此类分页:<font color=#FF0000>"&currentPage&"</font>/<font color=#FF0000><b>"&n&"</b></font>个,"
response.write "<meta http-equiv=Refresh content='0; URL=MakeHtml.asp?ItemName="&TypeItem&"&pageNo="&currentPage+1&"'>"
end if
end if
%>
这个绝对没问题我试过了。

中国人的财富网:http://www..cn/
2005-11-23 01:50
caiyakang
Rank: 2
等 级:新手上路
威 望:5
帖 子:2111
专家分:0
注 册:2005-3-24
收藏
得分:0 
你的那个能不能用?

中国人的财富网:http://www..cn/
2005-11-23 01:53
w462156
Rank: 1
等 级:新手上路
帖 子:28
专家分:0
注 册:2005-11-10
收藏
得分:0 

到现在我还没找到一个真正好用的分页.


我的要求是重新生成的时候.只生成最后的一到两个页面的分页.前面的就不必再重新生成.否则新闻越来越多.会越来越慢.

有人说用反向分页.我相信是可以实现.但那里的循环.条件等估计太复杂.我还没有做出来.不知道有哪位兄弟做出来过.

2005-11-23 16:26
syh878
Rank: 1
等 级:新手上路
威 望:2
帖 子:461
专家分:0
注 册:2005-9-2
收藏
得分:0 
fout.Write haha
应该用textstream

2005-11-24 09:51
快速回复:我很想了解静态分页的原理
数据加载中...
 
   



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

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