asp分页生成html的程序脚本代码
程序员文章站
2022-07-01 23:43:12
这是asp分页列表生成静态页面得asp小程序脚本 复制代码 代码如下: &l...
这是asp分页列表生成静态页面得asp小程序脚本
<!--#include file="conn.asp"-->
<html><head><title>分页测试</title><link href="inc/style.css" type=text/css rel=stylesheet></head>
<%strhead=strhead&"<html>"
strhead=strhead&"<head>"
strhead=strhead&"<title>分页测试</title>"
strhead=strhead&"<link href=""inc/style.css"" type=text/css rel=stylesheet>"
strhead=strhead&"</head>"
%>
<%
sql="select * from news"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
%><%
rs.pagesize=2
totalpage=rs.pagecount
rs.close
set rs=nothing
for j=1 to totalpage
sql="select * from news"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
whichpage=j
rs.pagesize=2
totalpage=rs.pagecount
rs.absolutepage=whichpage
howmanyrecs=0
%><%
str0=""
str0=str0&"</p>"
str0=str0&"<table bgcolor=#cecfce align=center border=0 width=800 cellpadding=2 cellspacing=1>"
%><%
do while not rs.eof and howmanyrecs<rs.pagesize
%><%
str0=str0&"<tr bgcolor=#f7f7f7>"
str0=str0&"<td bgcolor=#f7f7f7 align=""center"">"&rs(0)&"</td>"
str0=str0&"<td bgcolor=#f7f7f7 align=""center"">"&rs(1)&"</td>"
str0=str0&"<td bgcolor=#f7f7f7 align=""center"">"&rs(2)&"</td>"
str0=str0&"<td bgcolor=#f7f7f7 align=""center"">"&rs(3)&"</td>"
str0=str0&"</tr>"
%><%
rs.movenext
howmanyrecs=howmanyrecs+1
loop
rs.close
set rs=nothing
%><%str0=str0&"</table>"
%><%
'分页部分
ref=""
ref=ref&"<br>"
ref=ref&"<table bgcolor=#cecfce align=center border=0 width=800 cellpadding=0 cellspacing=1> "
ref=ref&"<tr bgcolor=#f7f7f7>"
ref=ref&"<td> "
ref=ref&"<b>pages: " & j & " / " & totalpage &"</b>"
ref=ref&"</td>"
ref=ref&"<td> "
ref=ref&"<a href=list_1.html"&">" & "<font face=webdings>9</font>" & "</a> "
if whichpage=1 then
ref=ref&"<font face=webdings>7</font>"
else
ref=ref&"<a href=list_"&j-1&".html"&">" & "<font face=webdings>7</font>" & "</a> "
end if
for counter=1 to totalpage
ref=ref&"<a href=list_"&counter&".html"&">[" & counter & "]</a>"
ref=ref& " "
if counter mod 10 = 0 then
ref=ref& "<br>"
end if
next
if (whichpage>totalpage or whichpage=totalpage) then
ref=ref&"<font face=webdings>8</font>"
else
ref=ref&"<a href=list_"&j+1&".html"&">" & "<font face=webdings>8</font>" & "</a> "
end if
ref=ref&"<a href=list_"&totalpage&".html"&">" & "<font face=webdings>:</font>" & "</a> "
dim fso,f
dim strtitle,strcontent,strout
'创建文件系统对象
set fso=server.createobject("scripting.filesystemobject")
set f=fso.createtextfile(server.mappath("list_"&j&".html"),true)
'写入网页内容
f.writeline strhead&str0&ref
f.close
response.write "正在生成第"&j&"个页面!<br>"
%><%
next%>
复制代码 代码如下:
<!--#include file="conn.asp"-->
<html><head><title>分页测试</title><link href="inc/style.css" type=text/css rel=stylesheet></head>
<%strhead=strhead&"<html>"
strhead=strhead&"<head>"
strhead=strhead&"<title>分页测试</title>"
strhead=strhead&"<link href=""inc/style.css"" type=text/css rel=stylesheet>"
strhead=strhead&"</head>"
%>
<%
sql="select * from news"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
%><%
rs.pagesize=2
totalpage=rs.pagecount
rs.close
set rs=nothing
for j=1 to totalpage
sql="select * from news"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
whichpage=j
rs.pagesize=2
totalpage=rs.pagecount
rs.absolutepage=whichpage
howmanyrecs=0
%><%
str0=""
str0=str0&"</p>"
str0=str0&"<table bgcolor=#cecfce align=center border=0 width=800 cellpadding=2 cellspacing=1>"
%><%
do while not rs.eof and howmanyrecs<rs.pagesize
%><%
str0=str0&"<tr bgcolor=#f7f7f7>"
str0=str0&"<td bgcolor=#f7f7f7 align=""center"">"&rs(0)&"</td>"
str0=str0&"<td bgcolor=#f7f7f7 align=""center"">"&rs(1)&"</td>"
str0=str0&"<td bgcolor=#f7f7f7 align=""center"">"&rs(2)&"</td>"
str0=str0&"<td bgcolor=#f7f7f7 align=""center"">"&rs(3)&"</td>"
str0=str0&"</tr>"
%><%
rs.movenext
howmanyrecs=howmanyrecs+1
loop
rs.close
set rs=nothing
%><%str0=str0&"</table>"
%><%
'分页部分
ref=""
ref=ref&"<br>"
ref=ref&"<table bgcolor=#cecfce align=center border=0 width=800 cellpadding=0 cellspacing=1> "
ref=ref&"<tr bgcolor=#f7f7f7>"
ref=ref&"<td> "
ref=ref&"<b>pages: " & j & " / " & totalpage &"</b>"
ref=ref&"</td>"
ref=ref&"<td> "
ref=ref&"<a href=list_1.html"&">" & "<font face=webdings>9</font>" & "</a> "
if whichpage=1 then
ref=ref&"<font face=webdings>7</font>"
else
ref=ref&"<a href=list_"&j-1&".html"&">" & "<font face=webdings>7</font>" & "</a> "
end if
for counter=1 to totalpage
ref=ref&"<a href=list_"&counter&".html"&">[" & counter & "]</a>"
ref=ref& " "
if counter mod 10 = 0 then
ref=ref& "<br>"
end if
next
if (whichpage>totalpage or whichpage=totalpage) then
ref=ref&"<font face=webdings>8</font>"
else
ref=ref&"<a href=list_"&j+1&".html"&">" & "<font face=webdings>8</font>" & "</a> "
end if
ref=ref&"<a href=list_"&totalpage&".html"&">" & "<font face=webdings>:</font>" & "</a> "
dim fso,f
dim strtitle,strcontent,strout
'创建文件系统对象
set fso=server.createobject("scripting.filesystemobject")
set f=fso.createtextfile(server.mappath("list_"&j&".html"),true)
'写入网页内容
f.writeline strhead&str0&ref
f.close
response.write "正在生成第"&j&"个页面!<br>"
%><%
next%>