快精灵印艺坊 您身边的文印专家
广州名片 深圳名片 会员卡 贵宾卡 印刷 设计教程
产品展示 在线订购 会员中心 产品模板 设计指南 在线编辑
 首页 名片设计   CorelDRAW   Illustrator   AuotoCAD   Painter   其他软件   Photoshop   Fireworks   Flash  

 » 彩色名片
 » PVC卡
 » 彩色磁性卡
 » 彩页/画册
 » 个性印务
 » 彩色不干胶
 » 明信片
   » 明信片
   » 彩色书签
   » 门挂
 » 其他产品与服务
   » 创业锦囊
   » 办公用品
     » 信封、信纸
     » 便签纸、斜面纸砖
     » 无碳复印纸
   » 海报
   » 大篇幅印刷
     » KT板
     » 海报
     » 横幅

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")
sql="select * from article where articleid="&articleid
rs.open sql,conn,3,3
"请注重:这里并没有加入rs.addnew表示只是对数据库的指定记录进行更新操作,而没有添加新的记录
rs("title")=title
rs("content")=content
rs("dateandtime")=date()
"更新数据库
rs.update
"关闭数据库连接
rs.close
set rs=noting
conn.close
set conn=nothing
"对数据库更新完毕后,把页面重新转向文章治理页面manage.asp
response.redirect "manage.asp"
%>

写到这里,我们的文章在线治理系统就算基本完成了,我也相信大家经过这些时间的学习已经把握了本系统的基本原理,也可以通过本专题建立自己的文章在线治理系统,不过在最后我还要向大家介绍本人对文章治理系统新添加的一段程序,也就是对治理员的名字和密码、文章栏目的在线修改删除添加程序,以使本系统更加完善,请看下一篇治理员&栏目治理篇.
返回类别: 教程
上一教程: RECORDSET的几个属性设置方式
下一教程: 用ASP实现网站的“目录树”治理

您可以阅读与"ASP进阶之文章在线治理更新(12)"相关的教程:
· ASP进阶之文章在线治理更新(3)
· ASP进阶之文章在线治理更新(4)
· ASP进阶之文章在线治理更新(1)
· ASP进阶之文章在线治理更新(13)
· ASP进阶之文章在线治理更新(5)
    微笑服务 优质保证 索取样品