Display Post Count for a Specifc Period

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wrestlingwire
    New Member
    • Feb 2004
    • 7

    Display Post Count for a Specifc Period

    I run contests on my forums where you get a drawing into the contest for every 10 posts you make during the contest period. I had someone help me coding it, but the problem with it is that it tallies all posts, even if they were made it a forum where a new post doesnt add to your post count. So I have members just posting a lot in the forums where posts dont count and getting their contest post count up, resulting in more contest entries. Could someone help me display the post count of only posts that count towards the user's post count during a specific time period? Here is what I have for my current contest:

    PHP Code:
    echo "<table width=\"450\" cellspacing=\"0\" cellpadding=\"1\" border=\"0\">
    <tr>
    <td><b><u>Username</u></b></td>
    <td><b><u>Contest Post</u></b></td>
    <td><b><u>Drawing Entries</u></b></td>
    </tr>"
    ;
    $dbQuery "SELECT a.username, COUNT(b.postid) AS postCount FROM user a, post b WHERE dateline > '1123963200'AND dateline < '1124683140' AND a.userid = b.userid GROUP BY b.userid ORDER BY postCount DESC"
    $dbResult mysql_query($dbQuery) or die(mysql_error() . " " $dbQuery); 
    while (
    $dbRow mysql_fetch_array($dbResult,MYSQL_ASSOC)) { 
    echo 
    "<tr>
    <td><font face=\"verdana\" size=\"1\">"
    .$dbRow['username']."</td>
    <td><font face=\"verdana\" size=\"1\">"
    .$dbRow['postCount']."</td>";
    $tickets $dbRow['postCount']*.1;
    $round floor($tickets);
    echo 
    "<td><font face=\"verdana\" size=\"1\">$round</td></tr>";
    }
    echo 
    "</table><br>
    </td>
    </tr>
    </table>"

    I'm new with PHP, so help would be greatly appreciated!
  • Lats
    Senior Member
    • Mar 2002
    • 3671

    #2
    Try changing your query to this...
    Code:
    SELECT 
        a.username, 
        COUNT(b.postid) AS postCount 
    FROM 
        user AS a, 
        post AS b 
    LEFT JOIN
        thread
    ON
        thread.threadid = b.threadid
    WHERE 
        b.dateline > '1123963200'
    AND 
        b.dateline < '1124683140' 
    AND 
        a.userid = b.userid 
    AND
        thread.forumid = [COLOR=Blue]3[/COLOR]
    GROUP BY 
        b.userid 
    ORDER BY 
        postCount DESC
    Change the 3 to the forumid where posts count towards the competition.
    Lats...

    Comment

    • wrestlingwire
      New Member
      • Feb 2004
      • 7

      #3
      Originally posted by Lats
      Try changing your query to this...
      Code:
      SELECT 
          a.username, 
          COUNT(b.postid) AS postCount 
      FROM 
          user AS a, 
          post AS b 
      LEFT JOIN
          thread
      ON
          thread.threadid = b.threadid
      WHERE 
          b.dateline > '1123963200'
      AND 
          b.dateline < '1124683140' 
      AND 
          a.userid = b.userid 
      AND
          thread.forumid = [COLOR=blue]3[/COLOR]
      GROUP BY 
          b.userid 
      ORDER BY 
          postCount DESC
      Change the 3 to the forumid where posts count towards the competition.
      How do I add multiple forumids? When I added others I went like this:
      AND
      thread.forumid = '3, 4, 5'
      That is not appearing to work. How can I add multiple ids? Thanks alot!

      Comment

      • Lats
        Senior Member
        • Mar 2002
        • 3671

        #4
        Multiple ids...
        Code:
        ...
           thread.forumid IN (3,4,5)
        ...
        Lats...

        Comment

        • wrestlingwire
          New Member
          • Feb 2004
          • 7

          #5
          It works great! I can't thank you enough. Thanks again!

          Comment

          • FamilyCorner
            Member
            • Jan 2002
            • 91

            #6
            If anyone read my post, never mind, I found it LOL
            Last edited by FamilyCorner; Sat 15 Oct '05, 9:17am.

            Comment

            widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
            Working...