当前位置: 首页 > 图文教程 > 网络编程 > ASP > ASP进阶之文章在线管理更新(6)

ASP
对连串英文自动换行的解决方法 IE5.5
怎样写你自己的EMAIL组件(原理)
ASP中有关timeout超时的体会
用ASP实现从SQL Server导出数据到Access
ASP向NT域中加一个用户
ASP乱码的解决方法
关于 aspsmartupload 注册问题
利用XML不离开页面刷新数据
IIS 处理 SEARCH 请求漏洞
不用组件实现上载功能(1)
不用组件实现上载功能(2)
在网页中实现OICQ里的头像选择的下拉框
仅用xsl和asp实现分页功能
如何使用context()方法将数据置入表格(XML)
利用ASP从远程服务器上接收XML数据
将数据库里面的内容生成EXCEL
怎样在ASP里面创建统计图表
加密你的Access数据库
利用global.asp定时执行ASP
加密QueryString数据

ASP进阶之文章在线管理更新(6)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 109 ::
收藏到网摘: n/a

  ASP进阶之文章在线管理更新--文章显示篇

作者:沙滩小子

  前面已经为大家介绍了文章的添加保存,接下来就应该讲讲文章的显示了。在这里,你更加可以看出ASP的简单易用性,仅仅是通过一个文件,就可以对数据库内的所有文章进行显示。它主要是通过从连接返回的文章号(articleid)和栏目的信息(typeid)来打开数据库中指定的记录以及指定显示所需要的内容。

  以下是文章显示页面(list.asp)的详细代码以及注解:

  "打开数据库连接
<!--#include file="conn.asp"-->
<html>
<%
  "定义变量
dim sql
dim rs
dim typename
dim typeid
dim rstype,typesql
  "接受返回的栏目信息并打开指定栏目记录集type
typeid=request("typeid")
set rstype=server.createobject("adodb.recordset")
  typesql="select * from type where typeID="&cstr(typeid)
  rstype.open typesql,conn,1,1
  "调用指定栏目名称并将其信息指定给typename
  typename=rstype("type")
  "关闭记录集
  rstype.close
%>
<head>
<title>ASP动网先锋|http://asky.on.net.cn</title>
<link rel="stylesheet" href="style.css">
</head>

<body>
<div align="center"><center>

<table border="1" width="97%" cellspacing="0" cellpadding="0" bordercolorlight="#000000"
bordercolordark="#FFFFFF">
  <tr>
    <td width="100%" bgcolor="#D0D0D0"><p align="center">
  "显示栏目信息
 栏目:<%=typename&%>
<%
  "打开指定记录集article,并通过返回的文章号id打开指定文章号的相关内容,在这里显示了文章号,加入日期,浏览数,文章标题以及文章内容
set rs=server.createobject("adodb.recordset")
sql="select * from artidle where articleid="&request("id")
rs.open sql,conn,1,1
%>
----文章编号:<%=rs("articleid")%>----加入日期:<%=rs("date")%>----浏览数:<%=rs("hits")%></td>
  </tr>
  <tr>
    <td width="100%"><p align="right"><a href="javascript:self.close()">『关闭窗口』</a></td>
  </tr>
  <tr>
    <td width="100%"><p align="center"><b><%=rs("title")%></b></td>
  </tr>
  <tr>
    <td width="100%">
    <blockquote>
      <br>
<%=rs("content")%>      <br>
      <br>
<p align=center>
  "这里是文章的EMAIL转发,通过一段sentemail程序来实现,下面将为大家介绍
<form method=Post action='sentemail.asp?id=<%=rs("articleid")%>'>
<b>发送文章到邮箱</b><br>
<input type='text' name='email' maxlength=20 class=smallInput>
  <input class=buttonface type='submit'  value='发送'  name='send'>
</form>
    </blockquote>
   </td>
  </tr>
</table>
</center></div>
</body>
</html>
<%
  "关闭记录集和数据库连接
rs.close
set rs=nothing
conn.close
set conn=nothing
%>

  以上就是文章的显示程序,在这里以一段很少的代码就实现了从数据库调用指定文章内容以及显示的过程,相信到这里你更能体会到ASP的功用了,在本节中提到了利用ASP在线发送文章到信箱的程序,那么下面我将为大家介绍关于文章转发邮箱功能!