Using ASP to build website forum DIY-3

Source: Internet
Author: User
Tags add date sql variable
(3) Create qbaord.asp page:
%
Boardid=request ("Boardid") ' takes out the Kanban ID number passed over from the previous page
Set conn = Server.CreateObject ("ADODB. Connection ")
Conn. Open "Driver={microsoft accessdriver (*.mdb)};d bq=" & Server.MapPath ("Bbssystem.mdb")
Set cmd = Server.CreateObject ("Adodb.command")
Set cmd. ActiveConnection = conn
Cmd.commandtext = "topic list"
ReDim param (0)//NOTE: Declare parameter array
Param (0) = CLng (Boardid)//NOTE: CLng can not be ignored
Set rs = cmd. Execute (, param)
%>
html>
head>
title> Topic list/title>
"Meta http-equiv=" Content-type "content=" text/html; charset=gb2312 ">
/head>
Body bgcolor= "#FFFFFF"
H1 align= "center" ><%=rs ("Kanban name")%> Board topic list Table width= "80%" border= "0" cellspacing= "0" cellpadding= "0" align= "center"
TR bgcolor= "#FFFFCC"
TD width= "89%" height= "21" > theme </td>
TD width= "11%" height= "21" > Number of articles </td>
/tr>
%
Todo
TOPICID=RS ("id")
Topicname=rs ("title")
Sum=rs ("Number of articles")
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>
Note: qboard.asp lists all the topics under a certain layout, and after clicking on the topic name, it goes to the appropriate topic list. This list is implemented by qtopic.asp, an ASP script. Qtopic.asp's program code is virtually indistinguishable from qboard.asp in nature, but differs in its own details, and is not intended to be spoken.
(4) After clicked the article title in the article List, will enter the article content browsing page article.asp:
%
Articleid=request ("ArticleID")
Set conn = Server.CreateObject ("ADODB. Connection ")
Conn. Open "Driver={microsoft accessdriver (*.mdb)};d bq=" & Server.MapPath ("Bbssystem.mdb")
Set cmd = Server.CreateObject ("Adodb.command")
Set cmd. ActiveConnection = conn
Cmd.commandtext = "Query article by ID"
ReDim param (0) ' statement
Param (0) = CLng (ArticleID) ' Cint cannot be ignored
Set rs = cmd. Execute (, param)
Author=rs ("Author id")
Title=rs ("title")
Data=rs ("date")
Rate=rs ("recommended degree")
Boardid=rs ("Kanban id")
Topicid=rs ("Subject ID")
Boardname=rs ("Kanban name")
Topicname=rs ("Subject name")
Content=rs ("content")
Content=replace (Content,vbcrlf, "</p> p>")
Content= "p>" & content& "/p>"
Note: This is a place to note that the Content field contains text for the memo type, which can contain newline characters. In the HTML display, you must replace the newline character (that is, the vbCrLf constant) with the HTML paragraph symbol. This will not disrupt the formatting of the original input when the paragraph and paragraph are connected. If you want to design better, you can use CSS to reset the meaning of the p> tag, set its test-indent properties, you can achieve the beginning of each paragraph of space.
(5) Add the number of clicks to a
Sql= "Update content table Set Click count = click Times +1where id=" & ArticleID
Conn.execute SQL
Note: Here is an SQL statement, not when the page is displayed, the corresponding table will be clicked on the number of times to add one, so that the number of articles to browse the statistics, and can be ranked in order. When I execute the statement, I find that the embedded variable name should be enclosed in a single quotation mark in the SQL statement, but I do not have a single quotation mark on the ArticleID variable here, and I am able to pass it, and I have always written this as an error. I don't know if it's because of the new version of ADO.
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> Author: Font color= "#FF3366" ><a href= "qauthor.asp?author=<%=author%>" ><%=author%> (/a></font>) Date of publication: "Font color=" #FF 3333 "> <%=data%>/font>
Kanban: Font color= "#FF3333" ><a href= "qboard.asp?boardid=<%=boardid%>" ><%=boardname%></a></font> Board main recommended: "Font color=" # FF3333 "> #rate # </font>/td>
/tr>
TR bgcolor= "#CCCCCC"
td> title: Font color= "#FF3333" > <%=title%>
Subject: "A href=" qtopic.asp?topicid= <%=topicid%> ">%=topicname%></a>/font><
/tr>
TR valign= "Top"
td>
hr>
Font color= "#FF3366" > article content:/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%" > about this topic <a Href= "submit.asp?topicid=<%=topicid%>&boardid= <%=boardid%>" > comment on/a> </td>
This connection allows users to express their views on the topic of this comment, which is what the next module is going to tell you, and click here.
/tr>
/table>
/td>
/tr>
/table>
/body>
/html>
%
Set rs=nothing
Conn.close
Set conn=nothing
%>
To this end, the article shows that the section is completed. Let's take a look at how the article published is implemented.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.