好学IT学院:IT信息技术分享交流平台
标签:ASP  来源:www.huinao.com  作者:汇脑信息技术  发布时间:2006-09-19  ★★★加入收藏〗〖手机版
摘要:ASP2HTML WITH TEMPLET我希望大家看到该标题就能让想象到它的功能:1,WITH TEMPLET意思是,生成的页面架构将采用某个已设定的模板,在此之前我的一篇教程中介绍过,希望各位在看本教程之前对ASP采用模板应熟悉下。(当……

6,显示数据库表记录,并做指向HTML页的链接:showit.asp

引用:

------------------------------

<!--#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

%>

------------------------------

7,修改数据内容页change.asp

修改数据内容,同时也需要修改更新对应的HTML页面。修改其实就是重新生成文件,且文件名和之前一样,类似文件的覆盖。

引用:

------------------------------

<!--#include file="conn.asp" -->

<!--#include file="lib.asp" -->

<%id=request.querystring("c_id")%>

<%

if request.form("submit")="change" then

c_title=request.form("c_title")

c_content=request.form("c_content")

c_id=request.form("c_id")

c_filepath=request.form("c_filepath")

Set rs = Server.CreateObject ("ADODB.Recordset")

sql = "Select * from c_news where c_id="&c_id

rs.Open sql,conn,3,2

rs("c_title")=c_title

rs("c_content")=c_content

rs("c_time")=now()

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{LogContent}quot;,now())

mb_code=replace(mb_code,"$cnleft{LogContent}quot;,c_title)

mb_code=replace(mb_code,"$cnright{LogContent}quot;,c_content)

%>

  • 好学触屏公众号虎力全开、杨帆起航!
  • 四大名著全套小学生版注音版
  • 诗词中的科学全4册
  • 曹文轩系列儿童文学全套画本