教大家如何利用ASP打造網(wǎng)站論壇DIY(2)(3)_ASP教程
推薦:對(duì)一些編程初學(xué)者的良言警句我始終認(rèn)為,對(duì)一個(gè)初學(xué)者來(lái)說(shuō),IT界的技術(shù)風(fēng)潮是不可以追趕的,而且也沒(méi)有能力去追趕。我時(shí)�?� 見自己的DDMM們把課本扔了,去賣些價(jià)格不菲的諸如C#, VB.Net 這樣的大部頭,這讓我感到非常痛心
注:在這個(gè)表中,除了可以由連接來(lái)顯示看板主題的內(nèi)容,還有一個(gè)斑竹查詢部分和板務(wù)處理部分,版主查詢可以是通過(guò)qAuthor.asp來(lái)實(shí)現(xiàn)的,它只是簡(jiǎn)單的從數(shù)據(jù)庫(kù)中取出作者訊息,并顯示出來(lái),這兒就不多說(shuō)了。而板務(wù)處理是由managerlogin.asp頁(yè)面來(lái)處理的。這屬于文章審閱模塊,我在后面再詳說(shuō)。
| 以下為引用的內(nèi)容: rs.movenext loop until rs.eof %> |
注:通過(guò)一個(gè)do … loop循環(huán),把紀(jì)錄集中所有的訊息都顯示了出來(lái)。
| 以下為引用的內(nèi)容: < /table> < div align="center"><br> |
點(diǎn)擊看板名稱可以得到主題列表,點(diǎn)擊板主名稱可以察看板主訊息
| 以下為引用的內(nèi)容: < /div> < /body> < /html> < % set rs=nothing conn.close set conn=nothing %> |
(3)打造qBaord.asp頁(yè)面:
| 以下為引用的內(nèi)容: < % boardid=request("boardid") '取出由上個(gè)頁(yè)面?zhèn)鬟f過(guò)來(lái)的看板ID號(hào) 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 = "主題列表" ReDim param(0) //注:聲明參數(shù)數(shù)組 param(0) = CLng(boardid)//注:CLng 不可忽略 Set rs = cmd.Execute( ,param ) %> < html> < head> < title>主題列表< /title> < meta http-equiv="Content-Type"content="text/html; charset=GB2312"> < /head> < body bgcolor="#FFFFFF"> < h1 align="center"><%=rs("看板名")%>板主題列表 </h1> < table width="80%" border="0"cellspacing="0" cellpadding="0"align="center"> < tr bgcolor="#FFFFCC"> < td width="89%" height="21">主題</td> < td width="11%" height="21">文章數(shù)</td> < /tr> < % do topicid=rs("id") topicname=rs("標(biāo)題") sum=rs("文章數(shù)") response.write "< tr>< td><a href=qtopic.asp?topicid=" & topicid& "&boardname=" & boardname& ">" & topicname &"< /a>< /td>" response.write "< td>" &sum & "< /td>< /tr>" rs.movenext loop until rs.eof %> < /table> < /body> < /html> |
注:qBoard.asp列出了某個(gè)版面下的所有的主題,在點(diǎn)擊了主題名稱后就會(huì)進(jìn)入相應(yīng)的主題文章列表。這個(gè)列表的是由qTopic.asp這個(gè)ASP腳本來(lái)實(shí)現(xiàn)的。Qtopic.asp的程序代碼在本質(zhì)上幾乎和qBoard.asp沒(méi)有區(qū)別,只是在各自的細(xì)節(jié)上有所區(qū)別,這兒也不打算再多講了。
(4)在點(diǎn)擊了文章列表中的文章標(biāo)題后,會(huì)進(jìn)入文章內(nèi)容瀏覽頁(yè)article.asp:
| 以下為引用的內(nèi)容: < % articleid=request("articleid") 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) ' Cint 不可忽略 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>" |
注:這是一個(gè)要注意的地方,在內(nèi)容字段中包含的是備忘類型的文本,其中可以包含換行字符。在HTML的顯示中,必須要把換行字符(也就是vbCrlf常數(shù))換成HTML的段落符號(hào)。這樣在段落與段落的銜接處,就不會(huì)打亂原來(lái)輸入時(shí)的格式。如果要設(shè)計(jì)的更好些,可以通過(guò)CSS來(lái)復(fù)位義< P>標(biāo)簽,設(shè)定其test-indent屬性,就可以實(shí)現(xiàn)每段開頭空格了。
(5)把點(diǎn)擊次數(shù)加一
| 以下為引用的內(nèi)容: sql="Update 內(nèi)容表 Set 點(diǎn)擊次數(shù)=點(diǎn)擊次數(shù) 1Where ID=" & articleid conn.execute sql |
注:這兒有一個(gè)SQL語(yǔ)句,沒(méi)當(dāng)頁(yè)面被顯示的時(shí)候,會(huì)把相應(yīng)的表中點(diǎn)擊次數(shù)字段加一,這樣就能夠?qū)ξ恼聻g覽的次數(shù)做出統(tǒng)計(jì),并可按順序排名。在執(zhí)行條語(yǔ)句的時(shí)候,我發(fā)現(xiàn):本來(lái)在SQL語(yǔ)句中,嵌入的變量名應(yīng)該加上單引號(hào)以與區(qū)別,但在這兒的articleid變量上我并沒(méi)有加單引號(hào),居然也能夠通過(guò),而我以前這樣寫從來(lái)都是會(huì)引發(fā)錯(cuò)誤的,不知是不是由于新版本的ADO的緣故。
| 以下為引用的內(nèi)容: 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> < br> < /td> < /tr> < tr valign="top"> < td height="18"> < table width="50%" border="0"cellspacing="0" cellpadding="0"align="right" bgcolor="#CCCCCC"> < tr> < td width="0%"> < /td> <td width="65%">關(guān)于此話題<a href="submit.asp?topicid=< %=topicid%>&boardid=<%=boardid%>">發(fā)表評(píng)論< /a></td> |
分享:ASP教程:學(xué)習(xí)ASP應(yīng)用Cookies的技巧什么是 Cookie?Cookie 其實(shí)是一個(gè)標(biāo)簽,經(jīng)�?赡苈牭降闹形姆g:小舔餅。當(dāng)你訪問(wèn)一個(gè)需要唯一標(biāo)識(shí)你的站址的 WEB 站點(diǎn)時(shí),它會(huì)在你的硬盤上留下一個(gè)標(biāo)記,下一次你訪問(wèn)同一個(gè)站點(diǎn)時(shí),站點(diǎn)的
- asp FSO 讀寫文件本文件實(shí)現(xiàn)代碼
- asp中isNull、isEmpty和空字符串的區(qū)別
- asp獲取用戶真實(shí)IP地址的方法
- asp連接sqlserver數(shù)據(jù)庫(kù)實(shí)現(xiàn)代碼
- asp中正則表達(dá)式過(guò)濾html代碼函數(shù)
- asp中g(shù)et post提交表單區(qū)別
- 網(wǎng)頁(yè)模板:ASP內(nèi)建對(duì)象Request
- xmlhttp的open方法使用詳解
- ASP的常用的自定義函數(shù)大全
- asp中用for循環(huán)的一個(gè)小技巧
- eWebEditor v3.8 列目錄
- ASP無(wú)組件分頁(yè)實(shí)現(xiàn)思路及代碼
- 相關(guān)鏈接:
- 教程說(shuō)明:
ASP教程-教大家如何利用ASP打造網(wǎng)站論壇DIY(2)(3)
。