网络编程
位置:首页>> 网络编程>> Asp编程>> 简单的ASP生成HTML并分页程序

简单的ASP生成HTML并分页程序

  发布时间:2009-07-20 12:32:00 

标签:html,分页,asp

<%
If(Request.QueryString("Page")="") Then
Page=1
Else
Page=Request.QueryString("Page")
End If
title="新闻资讯"
sql="Select id,title From news order by id desc"
set rs = server.CreateObject("Adodb.RecordSet")
rs.open sql,conn,1,1
If(rs.eof) Then
   strList="没有内容"
Else
   Rs.pagesize=2
   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 & "<A href='"&Rs(0)&".html'>"&Rs(1)&"</a><br>"
   Rs.movenext
   Next
   If(Int(Page)=1) Then
   PageFirst="[首页"
   Else
   PageFirst="[<a href=""Index.html"">首页</a>"
   End If
     
   If(Int(Page)=1)Then
   PageBack=" 上一页 "
   Else
   if (Int(Page)-1)=1 then
   PageBack=" <a href=""Index.html"">上一页</a> "
   else
   PageBack=" <a href=""Index_"&Page-1&".html"">上一页</a> "
   end if
   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=2 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="<html><title>$newtitle$</title><head></head><body><table border=0 width=700 align=center><tr><td width=100>$newtitle$</td><td>$newlist$<div align=center>$newpage$</div></td></tr></table>"

'TempContent=Conn.Execute("Select TempContent From Templet Where TempID=1")(0)
TempContent=replace(TempContent,"$newtitle$",title)
TempContent=replace(TempContent,"$newlist$",strList)
TempContent=replace(TempContent,"$newpage$",PageNav)

Set FSO = Server.CreateObject("Scripting.FileSystemObject")
if Page=1 then
Set Fout = FSO.CreateTextFile(Server.MapPath("../html/news/Index.html"))
else
Set Fout = FSO.CreateTextFile(Server.MapPath("../html/news/Index_"&Page&".html"))
end if
Fout.Write TempContent
Fout.Close
%>
<%If(Int(Page)<Int(TotalPage))Then%>
<html>
<head><title>完成</title>
<meta http-equiv="refresh" content="0;url=crefile.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%>

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com