PDA

View Full Version : Posting-Counter for special forums


Grendel
12-10-2002, 08:38 PM
What I need:

I want to show the total count of postings a user has made (already integrated in vb).
BUT:
I also want to show, how many postings a user has made in
- forum 1, 2, 4, 6, 10 and in
- forum 3, 5, 7, 8, 9

Is this possible?

Xenon
12-10-2002, 09:48 PM
where do you want to show it?

in getinfo or in every post?

Grendel
12-11-2002, 09:21 AM
In every post. :)
But if that means to much queries I would be satisfied with getinfo too ;)

Xenon
12-11-2002, 12:00 PM
well in every post would mean at least hacking of a lot of files, or really increasing the ammount of queries, so i'd say we shouldn't do this ;)

for getinfo it's nor problem:

open member.php
find $jointime = (time() - $userinfo[joindate]) / 86400; // Days Joined
if ($jointime < 1) { // User has been a member for less than one day.
$postsperday = "$userinfo[posts]";
} else {
$postsperday = sprintf("%.2f",($userinfo[posts] / $jointime));
}

before (or below, it's equal ;)) add this:
$forumposts = $DB_site->query_first("SELECT SUM(IF(thread.forumid IN (1, 2, 4, 6, 10), 1, 0) as first, SUM(IF(thread.forumid IN (3, 5, 7, 8, 9), 1, 0) as second FROM post LEFT JOIN thread USING(threadid)");

then you should be able to use $forumposts[first] and $forumposts[second] in your getinfo-template, put it where you want ;)

Grendel
12-11-2002, 01:25 PM
I think some brackets are missing (the IF is not closed). SQL-Error, if I try it like you wrote. If I add some brackets:
$forumposts = $DB_site->query_first("SELECT SUM(IF(thread.forumid IN (1, 2, 4, 6, 10), 1, 0)) as first, SUM(IF(thread.forumid IN (3, 5, 7, 8, 9), 1, 0)) as second FROM post LEFT JOIN thread USING(threadid)");(no sql error) the count is wrong:

2973 (48935/44152)

First number is the whole count, second the $forumposts[first], last the $forumposts[second]

Any guesses?

Grendel
12-11-2002, 01:29 PM
That means right now its counting all posts - but it only should count the posts of a specific user.

Xenon
12-11-2002, 01:47 PM
damn, of course you're right :)
i had it in my mind, but forgot to write it down also...

also damn brackets ;)

use this one:
$forumposts = $DB_site->query_first("SELECT SUM(IF(thread.forumid IN (1, 2, 4, 6, 10), 1, 0)) as first, SUM(IF(thread.forumid IN (3, 5, 7, 8, 9), 1, 0)) as second FROM post LEFT JOIN thread USING(threadid) WHERE userid=$userinfo[userid]");

Grendel
12-11-2002, 02:07 PM
Works!

Great! Big "Thank you" for your quick help!

Xenon
12-11-2002, 02:09 PM
:)
good to hear :)

you're welcome