ASP生成静态代码,可用模板技术,非常简单,以下是代码示例:
<%
If(Request.QueryString("Page")="") Then
Page=1
Else
Page=Request.QueryString("Page")
End If
SQL="Select ID,LTitle,LPostTime,LHits From Log_List order By ID DESC"
Set Rs = Server.CreateObject("Adodb.RecordSet")
Rs.Open SQL,Conn,1,1
If(Rs.EOF) Then
strList="没有内容"
Else
Rs.pagesize=30
Rs.AbsolutePage=Page
TotalPage=Rs.PageCount
For i=0 To rs.pagesize-1 '显示具体的数据内容了,i+(page*13-13)+1 这个解决分页后显示具体的编号
If Rs.eof Then Exit For
strList = strList & i+(Page*13-13)+1 & ":<A href='"&Rs(0)&".html'>"&Rs(1)&"</a><br>"
Rs.movenext
Next
If(Int(Page)=1) Then
PageFirst="[首页"
Else
PageFirst="[<a href=""Index_1.html"">首页</a>"
End If
If(Int(Page)=1)Then
PageBack=" 上一页 "
Else
PageBack=" <a href=""Index_"&Page-1&".html"">上一页</a> "
End If
If(Int(Page)=TotalPage)Then
PageNext=" 下一页 "
Else
PageNext=" <a href=""Index_"&Page+1&".html"">下一页</a> "
End If
If(Int(Page)=TotalPage)Then
PageLast="尾页]"
Else
PageLast="<a href=""Index_"&TotalPage&".html"">尾页</a>]"
End If
AbsPage="第<select onchange=""window.location='Index_'+this.options[this.selectedIndex].value+'.html'"">"
For j=1 To TotalPage
AbsPage=AbsPage&"<option value="&j
If(Cstr(j)=Cstr(Page))Then
AbsPage=AbsPage&" selected"
End If
AbsPage=AbsPage&">"&j&"</option>"
Next
AbsPage=AbsPage&"</select>页"
PageNav=PageFirst&PageBack&PageNext&PageLast&AbsPage
End If
TempContent=Conn.Execute("Select TempContent From Templet Where TempID=1")(0)
TempContent=replace(TempContent,"$ArticleList$",strList)
TempContent=replace(TempContent,"$PageNav$",PageNav)
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
Set Fout = FSO.CreateTextFile(Server.MapPath("Article/Index_"&Page&".html"))
Fout.Write TempContent
Fout.Close
%>
<%If(Int(Page)<Int(TotalPage))Then%>
<html>
<head><title>完成</title>
<meta http-equiv="refresh" content="0;url=CreateHtml_List.asp?Page=<%=Page+1%>">
</head>
<body>
第<font color=red><b><%=Page%></b></font>页生成完毕!
</body>
</html>
<%Else%>
生成文章分类完毕,共生成<font color=red><b><%=TotalPage%></b></font>页
<%End If%>
大型站长资讯类网站! https://www.nzzz.com.cn