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

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

作者:沙滩小子

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

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

"打开数据库连接

1<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="&amp;cstr(typeid)
rstype.open typesql,conn,1,1
"调用指定栏目名称并将其信息指定给typename
typename=rstype("type")
"关闭记录集
rstype.close

 1<head>
 2<title>ASP动网先锋|http://asky.on.net.cn</title>
 3<link href="style.css" rel="stylesheet"/>
 4</head>
 5<body>
 6<div align="center"><center>
 7<table border="1" bordercolordark="#FFFFFF" bordercolorlight="#000000" cellpadding="0" cellspacing="0" width="97%">
 8<tr>
 9<td bgcolor="#D0D0D0" width="100%"><p align="center">   
10"显示栏目信息   
11栏目:```
12=typename&amp;amp;
1   
2"打开指定记录集article,并通过返回的文章号id打开指定文章号的相关内容,在这里显示了文章号,加入日期,浏览数,文章标题以及文章内容   
3set rs=server.createobject("adodb.recordset")   
4sql="select * from artidle where articleid="&amp;amp;request("id")   
5rs.open sql,conn,1,1   

----文章编号:=rs("articleid")----加入日期:=rs("date")----浏览数:``` =rs("hits")

 1</tr>
 2<tr>
 3<td width="100%"><p align="right"><a href="javascript:self.close()">『关闭窗口』</a></p></td>
 4</tr>
 5<tr>
 6<td width="100%"><p align="center"><b>```
 7=rs("title")
 8```</b></p></td>
 9</tr>
10<tr>
11<td width="100%">
12<blockquote>
13<br/>   

=rs("content")

 1<br/>
 2<p align="center">   
 3"这里是文章的EMAIL转发,通过一段sentemail程序来实现,下面将为大家介绍   
 4<form action='sentemail.asp?id=```
 5=rs("articleid")
 6```' method="Post">
 7<b>发送文章到邮箱</b><br/>
 8<input class="smallInput" maxlength="20" name="email" type="text"/>
 9<input class="buttonface" name="send" type="submit" value="发送"/>
10</form>
11</p></blockquote>
12</td>
13</tr>
14</table>
15</center></div>
16</body>
17</html>
1   
2"关闭记录集和数据库连接   
3rs.close   
4set rs=nothing   
5conn.close   
6set conn=nothing   

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

Published At
Categories with Web编程
Tagged with
comments powered by Disqus