<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../inc/exconn.asp"-->
<%
'定义ceil函数,用于输出非整数的结果为整数部分+1
function ceil(num)
dim t
t=fix(num)
if num=t then
ceil=t
else
ceil=t+1
end if
end function
'ceil函数结束
dim rs,rs_count,sqlnews,sql_count
'搜索模板表中的模板
sqlnews="select news from html"
set rs=server.createobject("adodb.recordset")
rs.open sqlnews,conn,1,1
ListTmp=rs("news")
rs.close
sql_count="select * from ex_news where exdlai='新闻动态' order by id desc"
set rs_count=server.createobject("adodb.recordset")
rs_count.open sql_count,conn,1,1
if rs_count.eof then
response.Write("还没有任何要生成的页面")
end if
dim TotalFile
dim MaxPerPage
dim TotalPages
dim CurrentPage
'要生成的总文件数
TotalFile=rs_count.recordcount
'设置每列表页显示的文件数
MaxPerPage=8
'自定义函数ceil计算列表页总页数
TotalPages=ceil(TotalFile/MaxPerPage)
for CurrentPage=1 to TotalPages
'每页显示的文件
dim i
i=0
do while not rs_count.eof
i=i+1
PageTitle=PageTitle&""&rs_count("extitle")
TopHits=TopHits&rs_count("extitle")&" "
if i>=MaxPerPage then exit do
rs_count.movenext
loop
'替换模板模块中的内容
ListTmp=replace(ListTmp,"{body}",PageTitle)
'创建FSO对象
Set fso = Server.CreateObject("Scripting.FileSystemObject")
'设置FOS写入文件的路径和名称
Set fout = fso.CreateTextFile(server.mappath("../news_"&CurrentPage&".html"))
fout.Write ListTmp
fout.close
next
%>