国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > ASP > 正文

ASP批量生成靜態頁_ASP教程

2024-05-04 11:03:39
字體:
來源:轉載
供稿:網友

推薦:學ASp動態網頁必備:常用的38個函數
1.函數array() 功能:創建一個數組變量 格式:array(list) 參數:list 為數組變量中的每個數值列,中間用逗號間隔 例子: <% i = array ("1","2","3&quo

由于本人的空間收到限制,不能一次批量生成所有的靜態頁,所以自己寫了一個小程序和大家分享,程序相當簡單,高手莫要見笑!此代碼就是很浪費時間.代碼如下

<!--#include file="conn.asp"-->
<HTML><HEAD><TITLE>生成頁面</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<LINK href="style.css" type=text/css rel=stylesheet>
<META content="MSHTML 6.00.2900.3020" name=GENERATOR>
</HEAD>
<BODY bottomMargin=0 leftMargin=0 topMargin=0 rightMargin=0>
<BR style="OVERFLOW: hidden; LINE-HEIGHT: 3px">
<%
dim id
id=cint(request.querystring("id"))
if id="" then
id="1"
else
id=cint(request.querystring("id"))
end if

Dim totalnumber
sql="select id from table order by id DESC"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
rs.Movefirst
if not rs.eof then
TotalNumber=rs.recordcount
end if
獲取總數可以用一句代碼代替,這個相信朋友自己可以解決.
rs.close
set rs=nothing

Response.Write "<br><br>" & vbNewLine
Response.Write "<table width='400' border='0' align='center' cellpadding='0' cellspacing='0'>" & vbNewLine
Response.Write " <tr>" & vbNewLine
Response.Write " <td height='50'>總共 <font color='blue'><b>" & totalnumber & "</b></font> 個頁面,正在生成第 <font color='red'><b>" & ID & "</b></font> 個頁面…… </td>" & vbNewLine
Response.Write " </tr>" & vbNewLine
Response.Write "</table>" & vbNewLine
Response.Flush

If ID > totalnumber Then
Response.Write "恭喜您操作成功!"
Response.Flush
End If

creat(ID)
id=id 1
Response.Write "<meta http-equiv=""refresh"" content=""1;url=?ID="&id&""">"
%>
</BODY>
</HTML>

<%
Function creat(id)
sql="SELECT * from table where id="&ID
set rs=conn.execute(sql)
dim name
name=rs("name")
conn.execute(sql)
rs.close
set rs=nothing
dim fso
dim znwl
dim art
dim fw
set fso=createobject("scripting.filesystemobject")
set znwl=fso.opentextfile(server.mappath("模板頁"))
art=znwl.readall
znwl.close

art=replace(art,"{$name$}",name)
set fw=fso.createtextfile(server.mappath("生成頁存放位置及頁面名稱"),true)
fw.writeline art
fw.close
set fso=nothing
End Function
%>


另外還有一種方法比上面的方法快,但是占用CPU比較多,我的空間用下面的方法老出問題

<!--#include file="conn.asp"-->
<HTML><HEAD><TITLE>生成頁面</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<LINK href="style.css" type=text/css rel=stylesheet>
<META content="MSHTML 6.00.2900.3020" name=GENERATOR>
</HEAD>
<BODY bottomMargin=0 leftMargin=0 topMargin=0 rightMargin=0>
<BR style="OVERFLOW: hidden; LINE-HEIGHT: 3px">
<table border="1" width="100%" id="table1">
<tr>
<td>
<%
dim allid,ppp,id,totalnum
sql="select * from table order by id DESC"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
if not rs.eof then
do while not rs.eof
if allid="" then allid= rs("id") else allid= allid & ";" & rs("id")
rs.movenext
loop
else
If Rs.bof And Rs.EOF Then
Response.Write "還沒有找到任何文章!"
End if
end if
rs.close
set rs=nothing

allid=";" allid
ppp=split(allid,";")
totalnum=ubound(ppp)
for id=1 to totalnum
Session("id")=Session("id") 1
creat(id)
response.write "正在生成znwl_"&id&".htm...<br>"
next
%>
 </td>
</tr>
</table>
</BODY>
</HTML>

<%
Function creat(id)
sql="SELECT * from table where id="&ID
set rs=conn.execute(sql)
dim name
name=rs("name")
conn.execute(sql)
rs.close
set rs=nothing
dim fso
dim znwl
dim art
dim fw
set fso=createobject("scripting.filesystemobject")
set znwl=fso.opentextfile(server.mappath("模板頁"))
art=znwl.readall
znwl.close

%>

art=replace(art,"{$name$}",name)
set fw=fso.createtextfile(server.mappath("生成頁存放位置及頁面名稱"),true)
fw.writeline art
fw.close
set fso=nothing
End Function


這種方法快,但是你的空間要不受限制!--智能網絡

上面的方法僅供參考,并不是本人修改的最后版本,但是絕對好用.

分享:ASP技巧實例:幾行代碼解決防止表單重復提交
在很多情況下都需要防止相同的表單被多次提交,很多人的實現方法都比較復雜(代碼數量超過幾十行!!)下面提供一種只需使用幾行代碼的方法,輕松地實現了防止用戶刷新多次提交表單和使用后退鈕重

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 盈江县| 绥宁县| 桐城市| 博爱县| 通渭县| 益阳市| 壤塘县| 吉首市| 烟台市| 崇礼县| 石台县| 新晃| 韶山市| 昌平区| 景洪市| 凤庆县| 泰宁县| 麻栗坡县| 盱眙县| 桂林市| 岳西县| 石门县| 定安县| 台东县| 彩票| 孝昌县| 高台县| 延吉市| 武功县| 白水县| 玛沁县| 琼结县| 台北市| 正定县| 南城县| 长汀县| 佳木斯市| 广丰县| 贵溪市| 格尔木市| 衢州市|