超长文章分页并生成静态页实例

set rsn=server.CreateObject("adodb.recordset")
sqln="select top 1 * from vArticle where apage='"&abname&"'"
rsn.open sqln,conn,1,1
if not rsn.eof then
'do while not rsn.eof
'page_n=len(rsn("aContent"))-len(replace(rsn("aContent"),"[NextPage]",""))
page_n=split(rsn("aContent"),"[NextPage]")
for i=1 to Ubound(page_n)+1

set rs=server.CreateObject("adodb.recordset")
sql="select * from hy_moban where mname='资讯内页'"
rs.open sql,conn,1,1
okfile=rs("mcontent")
rs.close
set rs=nothing
'if i=1 then 
'ppage=1 
'else 
'ppage=i-1 
'end if 
'if i=1 and page_n+1>i then 
'npage=i+1 
'else 
'npage=page_n+1 
'end if
aFrom=split(rsn("aFrom")&"|","|")
if aFrom(0)="" then
naFrom="未知"
else
naFrom=aFrom(0)
end if
k=i-1
Ntitle=rsn("aTitle")&"|"&rsn("akeyword")
okfile=replace(okfile,"$Ntitle$",Ntitle)
okfile=replace(okfile,"$C_Title$",rsn("C_Title"))
okfile=replace(okfile,"$aTitle$",rsn("aTitle"))
okfile=replace(okfile,"$acount$",rsn("acount"))
okfile=replace(okfile,"$aIntime$",rsn("aIntime"))
okfile=replace(okfile,"$aFrom$",naFrom)
okfile=replace(okfile,"$aContent$",page_n(k))
okfile=replace(okfile,"$aInUser$",rsn("aInUser"))
apage=replace(rsn("apage"),".shtml","")
asetpage=""
for j=1 to Ubound(page_n)+1
if j=i then
asetpage=asetpage&"[<font color=red>"&i&"</font>]"
elseif j=1 then
asetpage=asetpage&"[<a href="&rsn("apage")&">"&j&"</a>]"
else
asetpage=asetpage&"[<a href="&apage&"-haowai-"&j&".shtml>"&j&"</a>]"
end if
next
'asetpage="<br><a href="""&apage&"_"&ppage&".shtml"">上一页</a> <a href="""&apage&"_"&npage&".shtml"">下一页</a>"
okfile=replace(okfile,"$aSetpage$",asetpage)
myear=year(rsn("aInTime"))&"-"&month(rsn("aInTime"))
if i=1 then
mypage=rsn("apage")
else
mypage=apage&"-haowai-"&i&".shtml"
end if
Set fso1 = Server.CreateObject("Scripting.FileSystemObject")
  Set fout1 = fso1.Createtextfile(Server.MapPath("/"&"article/"&myear&"/"&mypage),true)
 fout1.writeline okfile
fout1.close
'rsn.movenext
'loop
next
end if
rsn.close
set rsn=nothing

你可能感兴趣的:(分页)