首页 ┆ 网站地图 ┆ 在线留言 ┆ 游戏资讯 ┆ 资源下载 ┆ 端午节祝福 ┆ 迅雷在线影视 ┆淘宝手机在线充值 ┆淘宝游戏点卡充值 
设为首页
加入收藏
联系我们
高级搜索
您当前的位置: 主页>ASP专区>编程技巧>破解网站发布系统,ASP生成静态页面方法
破解网站发布系统,ASP生成静态页面方法
来源: 发布时间:2007-09-26 发布人: 浏览: 人次   字体: [ ]  

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)
%>

<%'生成HTML页面
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set fout = fso.CreateTextFile(Server.MapPath(c_filepath))
fout.WriteLine mb_code
fout.close
%>
<%response.redirect("showit.asp")%>
<%end if%>

<%
if id<>"" then
Set rs = Server.CreateObject ("ADODB.Recordset")
sql="select * from c_news where c_id="&id
rs.Open sql,conn,1,1
c_id=rs("c_id")
c_filepath=rs("c_filepath")
c_title=rs("c_title")
c_content=rs("c_content")
end if
%>

<form action="change.asp" method="post">
Title:<input type="text" name="c_title" value=<%=c_title%>><br>
Content:<br>
<textarea name="c_content" rows="8" cols="30"><%=c_content%></textarea><br>
<input type="submit" value="change" name="submit">
<input type="reset" value="Reset">
<input name="c_id" type="hidden" value="<%=id%>">
<input name="c_filepath" type="hidden" value="<%=c_filepath%>">
</form>

  8、删除记录页del.asp

  同样!删除,除了删除数据库表中的记录,与其对应的HTML页面也需删除。代码如下:

  引用:

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

<%
c_id = request.querystring("c_id")
sql = "Select * from c_news where c_id="&c_id
Set rs = Server.CreateObject ("ADODB.Recordset")
rs.Open sql,conn,2,3

filepath=rs("c_filepath")
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFile(Server.mappath(filepath))
Set fso = nothing

rs.delete
rs.close
Set rs = Nothing
conn.close
set conn=nothing
%>

<%response.redirect("showit.asp")%>

  四、其它功能

  模板管理页面:

  不会每次都是打开数据库表进行增加或者修改模板代码吧,所以,管理代码的页面程序不能少了,自己捣鼓下应该很简单的。当然,之前管理员的登录认证程序就不在书中交代了:)还有,如果设计了多个模板,那么在发表信息的时候应添加模板选择单选框,同样在执行转换HTML时,SQL选择的不同m_id了。

  不管怎么说,先把这些技术自己调试感受下。多多操作,相信“读书千遍,其意自见”。

共3页: 上一页 [1] [2] 3 下一页
相 关 文 章   发布商链接
·将ASP纪录集输出成n列的的表格形式显...
·ASP实现自动解压RAR文件的代码
·如何防止网页的内容被别人采集,非法...
·asp自动实时无刷新更新数据
·ASP实现从远程服务器上接收XML数据
·ASP单击链接直接下载文件的代码
·如何用ASP调用带参数存储过程?
·如何清理asp站点缓存的代码?
·asp获取字符长度函数和截取字符串函...
·asp防止用户刷新多次提交表单和使用...
 §最新评论:(评论内容只代表网友观点,与本站立场无关!)
网名: 验证码:  【所有评论】【↑返回顶部
评 分: 12 345
评论内容:(不能超过500字,请自觉遵守互联网相关政策法规。[按 Ctrl+Enter 可直接提交]
注意:请勿在本站发布政治话题、色情及违反法律的内容。
IT知道网 声明:刊登此文章是为了传递更多信息,文章内容仅供参考,转载请注明出处。
推 荐 文 章
·asp设置程序等待时间,使程序
·asp实现返回上一页和转到另一
·在asp中实现字符串过滤单引号
·asp调用mysql5.1显示中文乱码
·实例讲解ASP获取本地与服务IP
·ASP获得页面中第一张图片的地
·Asp在上传文件时中文变问号的
·asp既有效防采集又不影响搜索
·asp读取数据库数据并生成exce...
·利用windows计划任务实现定时
·asp防止用户刷新多次提交表单
·asp获取字符长度函数和截取字
·如何清理asp站点缓存的代码?
·如何用ASP调用带参数存储过程
·ASP单击链接直接下载文件的代
热 门 文 章
·asp获取字符长度函数和截取字...
·asp防止用户刷新多次提交表单...
·asp自动实时无刷新更新数据
·ASP单击链接直接下载文件的代...
·如何清理asp站点缓存的代码?
·利用windows计划任务实现定时...
·asp读取数据库数据并生成exce...
·Asp在上传文件时中文变问号的...
·如何防止网页的内容被别人采...
·asp调用mysql5.1显示中文乱码...
·实例讲解ASP获取本地与服务IP...
·asp实现返回上一页和转到另一...
·Asp及Web开发中的常见问题小...
·ASP实现自动解压RAR文件的代...
·ASP开发10条经验总结
网站首页 - 关于本站 - 加入收藏 - 网站地图 - 友情连接 - 在线留言 - 联系我们 - 返回顶部
Copyright © 2007 IT知道网.[冀ICP备07026896号]. All Rights Reserved .