asp制作中常用到的函數(shù)庫集合
更新時間:2007年11月03日 16:31:10 作者:
當(dāng)點擊了相應(yīng)文章的聯(lián)結(jié)后,就進入此文章的處理頁面managearticle.asp:
< %
articleid=request("articleid")
boardid=request("boardid")
if session("beenthere")< >boardidthen response.redirect "forums.asp"
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "driver={Microsoft AccessDriver (*.mdb)};dbq=" & Server.MapPath("bbssystem.mdb")
Set cmd = Server.CreateObject("ADODB.Command")
Set cmd.ActiveConnection = conn
cmd.CommandText = "按id查詢文章"
ReDim param(0)
param(0) = CLng(articleid)//注:Clng 不可忽略
Set rs = cmd.Execute( ,param )
author=rs("作者id")
title=rs("標(biāo)題")
data=rs("日期")
rate=rs("推薦度")
boardid=rs("看板id")
topicid=rs("主題id")
boardname=rs("看板名")
topicname=rs("主題名")
content=rs("內(nèi)容")
content=replace(content,vbCrlf,"</p>< p>")
content="< p>" & content& "< /p>"
set cmd=nothing
%>
< html>
< head>
< title>Untitled Document< /title>
< meta http-equiv="Content-Type"content="text/html; charset=GB2312">
< /head>
< body bgcolor="#E9E9E4">
< table width="89%" border="0"cellspacing="0" cellpadding="0"align="center">
< tr bgcolor="#CCCCCC">
< td>作者:< font color="#FF3366"><a href="qauthor.asp?author=< %=author%>">< %=author%> < /a>< /font>發(fā)表日期:< font color="#FF3333"><%=data%>< /font>
看板:< font color="#FF3333"><a href="qboard.asp?boardid=< %=boardid%>">< %=boardname%>< /a>< /font>板主推薦:< font color="#FF3333">#rate#</font>< /td>
< /tr>
< tr bgcolor="#CCCCCC">
< td>標(biāo)題:< font color="#FF3333"><%=title%>
主題:< a href="qtopic.asp?topicid=<%=topicid%>"> < %=topicname%>< /a> < /font>< /td>
< /tr>
< tr valign="top">
< td>
< hr>
< font color="#FF3366">文章內(nèi)容:< /font>< br>
< br>
< font color=blue>< %response.writecontent%>< /font>
< br>
< hr>
< /td>
< /tr>
< tr valign="top">
< form method="post" action="manageresult.asp">
< td height="18">
< table width="100%" border="1"cellspacing="1" cellpadding="1">
< tr>
< td width="29%">
< div align="right">
< input type="hidden" name="boardid"value="< %=boardid%>">
< input type="hidden" name="topicid"value="< %=topicid%>">
< input type="hidden" name="articleid"value="< %=articleid%>">
文章處理:< /div>
< /td>
< td width="12%" bordercolor="#006666">刪除:
< input type="radio" name="manage"value=1>
< /td>
< td width="30%" bordercolor="#006666">發(fā)表:
< input type="radio" name="manage"value=2>
推薦等級
< select name="select">
< option value="1">1</option>
< option value="2">2</option>
< option value="3" selected>3</option>
< option value="4">4</option>
< option value="5">5</option>
< /select>
< /td>
< td width="20%" bordercolor="#006666">以后再處理:
< input type="radio" name="manage"value=3>
< /td>
< td width="9%">
< input type="submit" name="Submit"value="確定">
< /td>
< /tr>
< /table>
< /td>
< /form>
< /tr>
< /table>
< /body>
< /html>
< %
set rs=nothing
conn.close
set conn=nothing
%>
注:這一頁和文章顯示模塊中的article.asp基本上是一樣的,僅僅是多加入了版主處理的窗體,在這兒就不多講了。
下面,要根據(jù)版主的處理過程,修該數(shù)據(jù)庫相應(yīng)部分
< %response.buffer=true%>
< html>
< head>
< title>文章處理< /title>
< meta http-equiv="Content-Type"content="text/html; charset=GB2312">
< /head>
< body bgcolor="#E9E9E4">
< %
articleid=request("articleid")
boardid=request("boardid")
topicid=request("topicid")
manage=request("manage")
'接受窗體內(nèi)容
response.write manage '顯示斑竹ID
if session("beenthere")< >boardidthen response.redirect "forums.asp"
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "driver={Microsoft AccessDriver (*.mdb)};dbq=" & Server.MapPath("bbssystem.mdb")
根據(jù)上頁中版主的操作,下面進行相應(yīng)的處理。
if CLng(request("manage"))=1 then
sql="delete from 內(nèi)容表 where id="& articleid
conn.execute sql
response.write "< h1>文章已經(jīng)被刪除</h1>"
response.write "< a href=>back</a>"
elseif CLng(request("manage"))=2then
sql="update 內(nèi)容表 set 發(fā)表=true whereid=" & articleid
conn.execute sql
sql="update 主題表 set 文章數(shù)=文章數(shù)+1where id=" & topicid
conn.execute sql
response.write "< h1>文章已經(jīng)發(fā)表</h1>"
response.write "< a href=>back</a>"
else
response.clear
response.redirect "boardmanager.asp?boardid="& boarded
end if
%>
< /body>
< /html>
< %
conn.close
set conn=nothing
%>
經(jīng)過上面幾步,所有的部分就算是基本完成了,當(dāng)然,這時還不能拿來用,擺不上臺面的。如果想要能夠拿得出來的話,還要在版面設(shè)計,客戶端資料驗證等方面多下一些功夫。不過那都是HTML的內(nèi)容了,和ASP沒多大的關(guān)系,這兒我就不多講了。
相關(guān)文章
chr(9)、chr(10)、chr(13)、chr(32)、chr(34)講解
chr(9)、chr(10)、chr(13)、chr(32)、chr(34)講解...2007-03-03asp下連接數(shù)據(jù)庫 ASP鏈接數(shù)據(jù)庫字符串大全總結(jié)
asp下連接數(shù)據(jù)庫 ASP鏈接數(shù)據(jù)庫字符串大全總結(jié)...2007-11-11javascript asp教程第二課--轉(zhuǎn)義字符
javascript asp教程第二課--轉(zhuǎn)義字符...2007-03-03