Blog Setup - Showing count of related comments

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Blog Setup - Showing count of related comments

    Hi,

    I am trying to set up my own basic blog using ASP.VBScript. The sql used to
    retreive the entries is:

    ========================
    SELECT * FROM entries
    ========================

    The fields in tbl entries are:
    -----------
    EntryID (pk)
    Date
    Title
    Subject
    -----------

    In access, the query used to retreive the count of comments for each entry
    is:

    =============================
    SELECT entries.Title, Count(Comments.CommentID) AS CountOfCommentID
    FROM entries INNER JOIN Comments ON entries.EntryID = Comments.EntryID
    GROUP BY entries.Title, entries.EntryID;
    =============================

    The fields in tbl Comments are;
    ------------------
    CommentID (pk)
    Date
    Name
    Title
    Comment
    Website
    EntryID (fk)
    --------------------

    On my .asp page I have a table where I will show the Title, Date and subject
    of my blog entry. Below it I want to show how many comments there are for
    each entry. The vbscript in my table looks like this:

    ============================
    <%
    While ((Repeat1__numRows <> 0) AND (NOT posts.EOF))
    %>
    <table width="450" border="1">
    <tr>
    <td colspan="2"><%=(posts.Fields.Item("Title").Value)% ></td>
    <td><%=(posts.Fields.Item("Date").Value)%></td>
    </tr>
    <tr>
    <td colspan="3"><%=(posts.Fields.Item("Subject").Value )%></td>
    </tr>
    <tr>
    <td>Comments(<%=(comments.Fields.Item("CountOfComm entID").Value)%>)</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    </table>
    <br>
    <%
    Repeat1__index=Repeat1__index+1
    Repeat1__numRows=Repeat1__numRows-1
    posts.MoveNext()
    Wend
    %>
    ===================================

    The value - <%=(comments.Fields.Item("CountOfCommentID").Value )%> - is what
    I need, but equal to the entryID of its associated entry from the Entries
    table. Can anyone give me some ideas as to how to associated each comment
    with its Blog entry.

    Hope I have explained myself correctly.

    Many thanks in advance for any and all help.

    Best Regards
    Darren

    [url]www.yourdesignz.co.uk[/url]



    Darren Guest

  2. Similar Questions and Discussions

    1. Blog not showing
      I connect to several blogs. One of them shows the blog template in the editor window so that it looks as if I'm working directly on the website....
    2. ASP Coding Problem, XMLDOM-related (or just language-related!)
      Hi, I'm hoping someone can help me with this problem. I'm not sure whether the problem lies with the software or with my understanding of the...
    3. Disable Options>Import Comments in Comments Pane
      A customer asked me to replace the logic of the Comments>Import Comments menu item. I can easily find and replace this menu item with the name...
    4. Showing highlights without numbers/comments
      I'm trying to print a document with just the highlights. There are actually no comments, but since highlights are considered comments, Acrobat is...
    5. To count a number of lines in C++ or Java or ASCII files by exluding white spaces and comments
      Hi all, We have huge files in Java and C++ and I need to count the total number of lines in each of them by excluding white spaces (from the...
  3. #2

    Default Re: Blog Setup - Showing count of related comments

    Darren wrote:
    > Hi,
    >
    > I am trying to set up my own basic blog using ASP.VBScript. The sql
    > used to retreive the entries is:
    >
    > ========================
    > SELECT * FROM entries
    > ========================
    >
    > The fields in tbl entries are:
    > -----------
    > EntryID (pk)
    > Date
    > Title
    > Subject
    > -----------
    >
    > In access, the query used to retreive the count of comments for each
    > entry is:
    >
    > =============================
    > SELECT entries.Title, Count(Comments.CommentID) AS CountOfCommentID
    > FROM entries INNER JOIN Comments ON entries.EntryID = Comments.EntryID
    > GROUP BY entries.Title, entries.EntryID;
    > =============================
    >
    <snip>

    Don't use two recordsets. All the information you need can be returned in a
    single recordset:

    SELECT e.EntryID, e.[Date], e.Title, e.Subject
    Count(c.CommentID) AS CountOfCommentID
    FROM entries e INNER JOIN Comments c ON e.EntryID = c.EntryID
    GROUP BY e.EntryID, e.[Date], e.Title, e.Subject

    HTH,
    Bob Barrows

    PS. "Date" is a reserved keyword (it's the name of a VBA function!) and
    should not be used for a field name. BlogDate would be a less ambiguous name
    for this field, wouldn't it? As well as CommentDate in the Comments table
    ...?
    See here for the list of keywords to be avoided when naming your database
    objects:
    [url]http://www.aspfaq.com/show.asp?id=2080[/url]
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Barrows Guest

  4. #3

    Default Re: Blog Setup - Showing count of related comments

    "Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
    news:u1yf2X#0DHA.2000@TK2MSFTNGP11.phx.gbl...
    |
    | Don't use two recordsets. All the information you need can be returned in
    a
    | single recordset:
    |
    | SELECT e.EntryID, e.[Date], e.Title, e.Subject
    | Count(c.CommentID) AS CountOfCommentID
    | FROM entries e INNER JOIN Comments c ON e.EntryID = c.EntryID
    | GROUP BY e.EntryID, e.[Date], e.Title, e.Subject

    That does seem like a more common sense appoach Bob. Thank you for that.

    | HTH,
    | Bob Barrows
    |
    | PS. "Date" is a reserved keyword (it's the name of a VBA function!) and
    | should not be used for a field name. BlogDate would be a less ambiguous
    name
    | for this field, wouldn't it? As well as CommentDate in the Comments table
    | ..?
    | See here for the list of keywords to be avoided when naming your database
    | objects:
    | [url]http://www.aspfaq.com/show.asp?id=2080[/url]

    Thank you for the heads up on that also.
    Much appreciated Bob.

    Best Regards
    Darren


    Darren \(at work\) Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139