首页|操作系统|软件开发|网页制作|媒体动画|数据库|ASP教程|ASP.NET教程|PHP教程|JSP教程|XML教程|建站资料|软件学院|行业资讯|平面设计|网络安全|晒IT论坛|IT人才
  位置: 晒IT >> ASP教程 >> ASP实例教程 >> 正文
 
 
ASP进阶之文章在线管理更新(12)
ASP进阶之文章在线管理更新(12)
 
 
ASP进阶之文章在线管理更新--文章修改篇

作者:沙滩小子

    上一节我们讲了文章的在线删除的具体实现方法,在这里我将为大家介绍关于文章管理系统的在线修改。在本系统中,提供在线修改是一项必不可少的内容,因为当大家在网上更新文章的时候,总会碰上这样那样的问题,一个不小心就会造成添加的失误,有时候是内容不全,也有可能是文章的栏目原来添加的时候选错了,同时也就是这样那样的错误才显得这个程序的必要性。

    文章的在线修改保存的程序其实和文章的添加和保存程序差不多,只是这里是对数据库进行更新,而文章添加则是对数据库进行新增记录,不过从总体上来说还是差不多的,所以这里我只是对那些两个程序的不同点进行注解,其他要是大家有什么不明白的地方可以看看本专题的第二、三节,下面就来为大家介绍实现这一功能的过程:

    (1).文件edit.asp,这个文件没有什么好讲的了,因为基本上和本系统的addarticle.asp程序是相同的,只有在文章标题和文章内容部分取了相应的数据库内容,以方便大家参考修改。
<!--#include file="conn.asp"-->
<%
if request.cookies("adminok")="" then
  response.redirect "login.asp"
end if
%>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
<link rel="stylesheet" type="text/css" href="style.css">
<title>修改文章</title>
</head>

<body>

<form method="POST" action="saveedit.asp?id=<%=request("id")%>">
  <div align="center"><center><table border="1" cellspacing="0" width="80%" bordercolorlight="#000000" bordercolordark="#FFFFFF" cellpadding="0">
    <tr>
      <td width="100%" bgcolor="#D0D0D0" height="20"><div align="center"><center><p><b>修 改 文 章</b></td>
    </tr>
    <tr align="center">
      <td width="100%"><table border="0" cellspacing="1" width="100%">
<%
dim sql
dim rs
sql="select * from article where articleid="&request("id")
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
                %>
        <tr>
          <td width="15%" align="right" height="30"><b>文章标题:</b></td>
          <td width="85%" height="30"><input type="text" name="txttitle" size="70"
          class="smallinput" maxlength="100" value="<%=rs("title")%>"></td>
        </tr>
        <tr>
          <td width="15%" align="right" valign="top"><b>文章内容:</b></td>
          <td width="85%"><textarea rows="15" name="txtcontent" cols="70" class="smallarea"><%content=replace(rs("content"),"<br>",chr(13))
            content=replace(content,"&nbsp;"," ")
            response.write content%></textarea></td>
        </tr>
        <tr>
          <td width="15%" align="right" valign="top" height="20"></td>
          <td width="85%"></td>
        </tr>
      </table>
      </td>
    </tr>
  </table>
  </center></div><div align="center"><center><p><input type="submit" value=" 修 改 "
  name="cmdok" class="buttonface">&nbsp; <input type="reset" value=" 复 原 "
  name="cmdcancel" class="buttonface"></p>
  </center></div>
</form>
</body>
</html>
<%
rs.close
set rs=nothing
  conn.close  
  set conn=nothing  
%>

    (2).文件SaveEdit.asp,这里的保存修改文件也和添加文章中的保存差不多,只不过它是对数据库进行更新,而添加文章中的保存是对数据库进行添加新记录操作。

    "打开数据库连接
<!--#include file="conn.asp"-->
    "打开对文章内容的代码进行转化文件
<!--#include file="inc/articlechar.inc"-->
<%
if request.cookies("adminok")="" then
  response.redirect "login.asp"
end if
%>
<%
dim typename
dim title
dim content
dim sql
dim rs
dim articleid
title=htmlencode2(request.form("txttitle"))
content=htmlencode2(request.form("txtcontent"))
articleid=request("id")
   "打开数据库指定记录集中的指定记录,并对其进行更新操作
set rs=server.createobject("adodb.recordset")
[1] [2]  下一页
  • 上一篇: ASP进阶之文章在线管理更新(13)
  • 下一篇: ASP进阶之文章在线管理更新(11)
  •  告诉好友  打印此文 关闭窗口 返回顶部
     
    热点文章
     
     
    推荐文章
     
     
    相关文章

    | 设为首页 | 加入收藏 | 联系我们 | 友情链接 | 诚聘英才 |
    Copyright© 2008 ShaiIT.Com .All Rights Reserved
    下载alexa工具,提升您的网站排名