top
Loading...
ASP進階之文章在線管理更新(五)
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在線發送文章到信箱的程序,那么下面我將為大家介紹關于文章轉發郵箱功能!

轉載請注明出處http://asky.on.net.cn

北斗有巢氏 有巢氏北斗