首页 | 免费域名 | 个人服务器 | 一流信息监控拦截系统 | 虚拟主机知识库 | ASP 空间 | ASP技术大全 | 下载中心 | 客户服务中心
  7i24 > ASP技术大全 > 代码乐园 >
    7i24 .Com  
  多层回复的基于 ASP 的留言板(二)

7i24.Com不停为您服务
多层回复的基于 ASP 的留言板(二)

<%
 Set rsPosts = Server.CreateObject("ADODB.Recordset")
 sql = "SELECT BulletinBoard.PostID AS Post, BulletinBoard.BBName, "
& _
    "BulletinBoard.BBEmail, BulletinBoard.Subject, " & _
    "BulletinBoard.ResponseTo, BulletinBoard.BBDate, " & _
    "BulletinBoard.BBTime " & _
    "FROM BulletinBoard " & _
    "WHERE ResponseTo = 0 AND BBDate >(Date()-90) ORDER BY BBDate
DESC"

 rsPosts.open sql, conn, 3, 3
 If rsPosts.eof = false then
%>

<!-- In an Access database, you get the current date by the simple
command Date().
 Other databases use different syntaxes, so this code may have to
be tweaked a
 bit. I am limiting the date so that we don't get 3000 posts on the
same page.
 If your bulletin board was very active, you could limit the date
further.
 If you averaged a post a day, you could make it longer. -->

<!-- The extra "if eof" looks redundant but avoids the server going
to the next
 command unless it is necessary -->

<%
 On Error Resume Next
 rsPosts.MoveFirst

 do while Not rsPosts.eof
  'I explicitly declare the value of "post" here for later use
  Post = rsPosts("Post")
  BBDate = rsPosts("BBDate")

  'I have chosen to use images rather than <ul> so that I can
  'use a different image depending on the "freshness" of the post

  If BBDate = Date() then %>
   <img src="../../images/anibutton.gif" align="absmiddle"
     width="15" height="14">
<% ElseIf BBDate = (Date() -1 ) then %>
   <img src="../../images/button.gif" align="absmiddle"
     width="15" height="14">
<% ElseIf BBDate = (Date() -2 ) then %>
   <img src="../../images/button2.gif" align="absmiddle"
      width="15" height="14">
<% Else %>
   <img src="../../images/button4.gif" align="absmiddle"
      width="15" height="14">
<% End If

  'Display info about post here

  rsPosts.MoveNext
 loop
%>


得到回答将使用询问的一样的类型, 作为将得到回答到回答。但是我认识到了那以便显示有序的帖子, 从原来的帖子,然后反应, 然后到反应的反应等等, 我需要了到那些查询环的巢!

因此,我在显示信息之间插入了第 2 询问并且MoveNext循环。这询问对第一个几乎相同, 除了一些次要的变化。首先, 我将想要给我的变量一个稍微不同的名字。如果我把多重的值命名PostID, 将有我至于此变量意味着了的一些混乱。

这容易被使用解决SELECT AS.使它简单,PostID将被选择作为PostID2, 等等。然后我将为帖子的第一集合有一套变量,然后第二, 等等。我将也改变标准我的SELECT语句。我声明了值Post, 因此现在我想要所有的帖子在哪儿ResponseTo等于了值
PostID当在先前的循环声明了:

<%
 Set rsPosts2 = Server.CreateObject("ADODB.Recordset")
 sql = "SELECT BulletinBoard.PostID AS Post2, " & _
    "BulletinBoard.BBName AS BBName2, " & _
    "BulletinBoard.BBEmail AS BBEmail2, " & _
    "BulletinBoard.Subject AS Subject2, " & _
    "BulletinBoard.Message AS Message2, " & _
    "BulletinBoard.ResponseTo AS ResponseTo2, " & _
    "BulletinBoard.BBHomepageName AS BBHomepageName2, " & _
    "BulletinBoard.BBHomepageURL AS BBHomepageURL2, " & _
    "BulletinBoard.ImageURL AS ImageURL2, " & _
    "BulletinBoard.BBDate AS BBDate2, " & _
    "BulletinBoard.BBTime AS BBTime2 " & _
    "FROM BulletinBoard " & _
    "WHERE ResponseTo = " & Post & " ORDER BY BBDate DESC"

 rsPosts2.open sql, conn, 3, 3

 If rsPosts2.eof = false then

  'This section is a repeat of the section in the first loop,
except
  'all our variables are now VariableName2, and an extra blank
image
  'is added just before the button gif to mimic the spacing we would
  'have gotten using <ul>

 else
  'if eof is TRUE, jump right here to the end!
 end if

 rsPosts2.close
 set rsPosts2 = nothing
%>



  2002年1月9日  阅读 1255 次  发送此页给朋友  来源:    版权争议  删除

相关文章:   近期热点:

上一篇: 多层回复的基于 ASP 的留言板(一)
下一篇: 多层回复的基于 ASP 的留言板(三)
返回上一层...
搜索:

(C)2004-2022 7i24.Com 保留所有权利