这两天利用空闲时间编程序,琢摩了一下关于长文章分页以及页码条的简单实现方法。
思路是vbscript的。
currentpage=request.querystring(“page”)
currentpage是当前页的意思
pagecount = int(len(content)/size) + 1
content是长文章内容
size是每一页显示字数
pagecount是最后一页的页码
start=cint((currentpage-1)*size+1)
start是每一页的启始字数
if start<1 then start=1
content=mid(content,start,size)
以上截取出来每一页的文字
下面是显示页码条,胡想的,不过挺简单的,也挺实用。。。我觉得用于一般的分页够了。
pagebar_count的意思是每一次显示多少个页码,不太准的,因为我除二取整了(咳,差不多就行了,呵呵)
pagebar=”<br/><a href=”””&filename&”?act=view&id=”&id&”&page=1″”>[<<]</a>”
for i=currentpage-cint(pagebar_count/2) to currentpage+cint(pagebar_count/2)
if i>0 and i<=pagecount then pagebar=pagebar&”<a href=”””&filename&”?act=view&id=”&id&”&page=”&i&”””>[“&i&”]</a>”
next
pagebar=pagebar&”<a href=”””&filename&”?act=view&id=”&id&”&page=”&pagecount&”””>[>>]</a>”
出处:sipo blog
http://www.dc9.cn/post/272.html