简单的ASP生成HTML并分页程序
时间:2009-07-20 12:32:00
<%
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%>
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
javascript 45种缓动效果(一)
将SQL 2000日志迁移到SQL Server 2008
用一条SQL实现:一行多个字段数据的最大值
SQL Server 2000 作数据库服务器的优点
ASP实现全站的301跳转
Asp模板制作方法详解
如何把IP表存到SQL数据库里去?
Microsoft Office Access 2007使用技巧
![](https://img.aspxhome.com/file/UploadPic/20085/23/access2007_34s.gif)
学习完全掌握纯CSS布局网页
msxml3.dll 错误解决办法
网页新窗口打开好不好,数据说话
![](https://img.aspxhome.com/file/UploadPic/up/2008053117181324.gif)
sql查询点滴记录
PHP文件上传功能实现逻辑分析
一个比较完美的spacer div技巧
asp利用Split函数进行多关键字检索
页面加载对访问的影响
![](https://img.aspxhome.com/file/UploadPic/200910/30/speed_taobaoued-30s.png)