Recommended: Must-have for learning ASp dynamic web pages: 38 commonly used functions 1. Function array() function: Create an array variable format: array(list) Parameter: list is each numeric column in the array variable, with comma spacing example: <% i = array (1,2,3&quo
Since my space is limited, I cannot generate all static pages in batches at once, so I wrote a small program to share with you. The program is quite simple, so don't laugh at experts! This code is a waste of time. The code is as follows
<!--#include file=conn.asp--> <HTML><HEAD><TITLE>Generate Page</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 total number 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 To get the total number, you can use a code instead. I believe that friends can solve this problem by themselves. rs.close set rs=nothing Response.Write <br><br> & vbNewLine Response.Write <table width='400' border='0' align='center' cellpadding='0' cellpacing='0'> & vbNewLine Response.Write <tr> & vbNewLine Response.Write <td height='50'>Total color='blue'><b> & totalnumber & </b></font> pages are being generated... </td> & vbNewLine Response.Write </tr> & vbNewLine Response.Write </table> & vbNewLine Response.Flush If ID > totalnumber Then Response.Write Congratulations on your successful operation! 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(template page)) art=znwl.readall znwl.close art=replace(art,{$name$},name) set fw=fso.createtextfile(server.mappath(generated page storage location and page name), true) fw.writeline art fw.close set fso=nothing End Function %> |
There is another method that is faster than the above method, but it occupies a lot of CPU. I have problems with my space using the following method.
<!--#include file=conn.asp--> <HTML><HEAD><TITLE>Generate Page</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 No articles have been found yet! End if end if rs.close set rs=nothing allid=; allid ppp=split(allid,;) Totalnum=ubund(ppp) for id=1 to totalnum Session(id)=Session(id) 1 creat(id) response.write is generating 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(template page)) art=znwl.readall znwl.close %> art=replace(art,{$name$},name) set fw=fso.createtextfile(server.mappath(generated page storage location and page name), true) fw.writeline art fw.close set fso=nothing End Function |
This method is fast, but your space must be unlimited!--Smart Network
The above method is for reference only and is not the last version I modified, but it is definitely easy to use.
Share: ASP tip example: Several lines of code solve the problem of preventing repeated submission of forms In many cases, it is necessary to prevent the same form from being submitted multiple times. Many people's implementation methods are relatively complicated (the number of code exceeds dozens of lines!!) The following provides a method that only requires a few lines of code, which easily prevents users from refreshing multiple submissions and using the back button to re-examine the form.