[修改回复]
删除回复
插入表情:
宋体
楷体
幼圆
黑体
隶书
华文行楷
方正舒体
Arial
Arial Black
Arial Narrow
Century Gothic
Comic Sans MS
#0000FF
#8A2BE2
#DEB887
#5F9EA0
#7FFF00
#000000
#D2691E
#FF7F50
#FF0000
#DC143C
#99ccff
字体颜色
#FFF8DC
#00FFFF
#EE82EE
#F5DEB3
#FFFFFF
#F5F5F5
#FFFF00
#9ACD32
使用帮助
[quote]<%'容错处理 On Error Resume Next %> <!--#include file="conn.asp" --> <!--#include file="lib.asp" --> <%'接受传递值 c_title=request.form("c_title") c_content=request.form("c_content") %> <%'生成HTML文件名,建立文件夹,指定文件路径 fname = makefilename(now()) 'makefilename为自定义函数 folder = "newsfile/"&date()&"/" filepath = folder&fname %> <%'将接受值及路径保持至数据库表 sql = "Select * from c_news" Set rs = Server.CreateObject ("ADODB.Recordset") rs.Open sql,conn,3,2 rs.addnew rs("c_title")=c_title rs("c_content")=c_content rs("c_filepath")=filepath rs.update rs.close Set rs = Nothing %> <%'打开模板代码,并将其中特殊代码转变为接受值 sql1="select m_id,m_html from c_moban where m_id=1" set rs1=Server.CreateObject("adodb.recordset") rs1.open sql1,conn,1,1 mb_code=rs1("m_html") rs1.close set rs1=nothing conn.close set conn=nothing c_title=htmlencode(c_title) c_content=htmlencode(c_content) mb_code=replace(mb_code,"$cntop$",now()) mb_code=replace(mb_code,"$cnleft$",c_title) mb_code=replace(mb_code,"$cnright$",c_content) %> <%'生成HTML页面 Set fso = Server.CreateObject("Scripting.FileSystemObject") fso.CreateFolder(Server.MapPath(folder)) Set fout = fso.CreateTextFile(Server.MapPath(filepath)) fout.WriteLine mb_code fout.close %> 文章添加成功,<a href="showit.asp">浏览</a> [/quote] 6,显示数据库表记录,并做指向HTML页的链接:showit.asp [code]<!--#include file="conn.asp" --> <!--#include file="lib.asp" --> <% Set rs = Server.CreateObject ("ADODB.Recordset") sql = "Select * from c_news order by c_id desc" rs.Open sql,conn,1,1 %> <% if rs.EOF and rs.BOF then response.write ("暂时还没有文章,<a href=add.html>添加</a>") else Do Until rs.EOF %> <table width="758" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#000000"> <tr> <td width="159" align="right" bordercolor="#CCCCCC" bgcolor="#CCCCCC"><%=rs("c_time")%></td> <td width="591" bordercolor="#f3f3f3" bgcolor="#f3f3f3"><a href=<%=rs("c_filepath")%> target="a_blank"><%=rs("c_title")%></a></td> </tr> <tr> <td valign="top" align="right" bordercolor="#ececec" bgcolor="#ececec">[<a href=del.asp?c_id=<%=rs("c_id")%>>Dell</a>][<a href=change.asp?c_id=<%=rs("c_id")%>>Edit</a>][<a href="add.html">Add</a>]</td> <td valign="top" bordercolor="#FFFFFF" bgcolor="#FFFFFF"><%=htmlencode(rs("c_content"))%></td> </tr> </table><br> <% rs.MoveNext Loop end if %> <% rs.close Set rs = Nothing conn.close set conn=Nothing %> [/code]
不能为空
不能含有 ` 字符,字数8000以内
(CTRL+ENTER提交)
关闭窗口