网站首页 | 图形处理 | 网页设计 | 编程学习 | 操作系统学习 | 办公软件学习 | 常用软件学习 | 视频教程 | 设计作品欣赏| IT认证 | 设计素材下载 | 常用软件下载


 asp留言板教程


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
%>



  • 上一篇教程:
  • 下一篇教程: 没有了

  •  
    推荐

    最新
    · asp留言板教程
    · asp语法教程
    · C语言-编程实例-很普通很…
    · C语言-编程实例-三视图的…
    · C语言-编程实例-我编的国…
    · C语言-编程实例-用递归法…
    · C语言-编程实例-C与脚本…
    · C语言-编程实例-c语言优…
    · C语言-编程实例-输入一串…
    · C语言-编程实例-跳动的小…

     

    没有任何图片教程



    本站提供大量Photoshop照片处理,语言编程,网页设计制作,windows系统等软件在线实例教程,欢迎你投稿你的设计作品.lhy514251@163.com

    粤ICP备06081596