ASP進階之文章線上管理更新(五)

來源:互聯網
上載者:User
線上 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



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.