PDA

View Full Version : Forum-Subforum Post Count


webhost
08-31-2001, 04:37 PM
I have a forum with say 7 sub-forums. Is it possible to show the total posts of these just by their selves on the opening page? Like forumid "Name" Total Posts = 37 FOR EXAMPLE

Admin
08-31-2001, 04:46 PM
I don't understand... :confused:
Where and what do you want to show?

Bane
08-31-2001, 04:51 PM
The total number of posts for all 7 sub-forums on the main forum? Or on the main page?

webhost
08-31-2001, 05:03 PM
I have a forum with 7 subforums. I have made them invisible because I could not get the color scheme right to match the board because of getting the last thread hack to work with subforums. I didn't want to show all of these sub-forums on the opening page. So like I said I made them invisible. Then in the forumhome template I placed a table to place the link for the hidden sub forums. That way it only takes up one space on the board. This table has the same look as the rest of the board. Same heading color same forum look, and I have a link in it called Latest News Here. When you click it, the 7 subforums open up which shows total threads and total posts in each column for each sub-forum. What I want to do is add all of those subforum posts counts up and display that number on the opening page in the table I have created with the link called Latest News Here, right beside it.
Go to my forums in my signature and look for this at the bottom.

Look under here for all information pretaining to WNG listed here. Includes News Releases, Court Proceedings, Raytheon and other.

Information Here:Latest News Items

Joey

Admin
09-01-2001, 06:09 AM
Umm, I think that if you put this in your index.php:
$invpost=$DB_site->query_first("SELECT count(*) AS posts FROM post WHERE forumid=29");
$invthread=$DB_site->query_first("SELECT count(*) AS threads FROM thread WHERE forumid=29");
and use $invpost[posts] and $invthread[threads] will do what you need.

EDIT:
Place it somewhere here:
// get total posts
$countposts=$DB_site->query_first('SELECT COUNT(*) AS posts FROM post');
$totalposts=$countposts['posts'];
if ($totalposts=='') {
$totalposts=0;
}
$countthreads=$DB_site->query_first('SELECT COUNT(*) AS threads FROM thread');
$totalthreads=$countthreads['threads'];
if ($totalthreads=='') {
$totalthreads=0;
}

// get number of posts today
$datecut=time()-(86400);
$getpoststoday=$DB_site->query_first("SELECT count(*) AS count FROM post WHERE dateline>='$datecut'");
$poststoday=$getpoststoday[count];

// get newest member
$getnewestusers=$DB_site->query_first("SELECT userid,username FROM user WHERE userid=$numbersmembers[max]");
$newusername=$getnewestusers['username'];
$newuserid=$getnewestusers['userid'];
I think that shouldn't cause any problems.

webhost
09-01-2001, 07:15 AM
Small problem, I installed your script in index.php and when tried to open forum I got the error below. I then went and put 2 new fields in forum table in database called invpost and invthread but still got error.

There seems to have been a slight problem with the database. Please try again by pressing the refresh button in your browser.

An E-Mail has been dispatched to our Technical Staff, who you can also contact if the problem persists.

We apologise for any inconvenience.

Database error in vBulletin: Invalid SQL: SELECT count(*) FROM post WHERE forumid=29
mysql error:
mysql error number:
Date: Saturday 01st of September 2001 02:15:35 AM
Script: /
Referer:

Admin
09-01-2001, 07:18 AM
Sorry, forgot the AS part.
Updated my post, the variables are a bit diff as well.

webhost
09-01-2001, 07:25 AM
Problem still here I placed this index.php


$invpost=$DB_site->query_first("SELECT count(*) AS posts FROM post WHERE forumid=29");
$invthread=$DB_site->query_first("SELECT count(*) AS threads FROM thread WHERE forumid=29");

There seems to have been a slight problem with the database. Please try again by pressing the refresh button in your browser.

An E-Mail has been dispatched to our Technical Staff, who you can also contact if the problem persists.

We apologise for any inconvenience.


Database error in vBulletin: Invalid SQL: SELECT count(*) AS posts FROM post WHERE forumid=29
mysql error:
mysql error number:
Date: Saturday 01st of September 2001 02:24:14 AM
Script: /
Referer:

webhost
09-01-2001, 07:48 AM
I added like I said above to the forum table, do you think we need to add fields to the post and thread tables in the database?

Admin
09-01-2001, 09:22 AM
NO, don't do that.

I'll try this myself and get back to you. This should work damnit.

Admin
09-01-2001, 11:09 AM
$invposts=$DB_site->query_first("SELECT replycount FROM forum WHERE forumid=1");
$invthreads=$DB_site->query_first("SELECT COUNT(*) AS threadcount FROM thread WHERE forumid=1");
Now use $invposts[replycount] and $invthreads[threadcount].
The thread count doesn't show up. Grr...

Admin
09-01-2001, 11:23 AM
Oh wait, they do show up. I had the wrong forumid set for me. :p

webhost
09-01-2001, 11:25 AM
I am working now, I changed the id the replycount/post show up correctly and the threadcount shows zero, should have a number of 107 according to forum and database. This what I havw in forumhome template.




<tr>
<td bgcolor="#FFFFFF" colspan="6"><normalfont color="{categoryfontcolor}"><p align="left"> Look under here for all information pretaining to WNG listed here. Includes News Releases, Court Proceedings, Raytheon and other.<br>$invposts[replycount] <br>$invthreads[threadcount]<br><br>

Information Here:<b><a href="http://forums.realwebhost.net/forumdisplay.php?forumid=29">Latest News Items</a></b></p></normalfont></td>
</tr>

Admin
09-01-2001, 11:31 AM
Oh right, you have subforums IN the subforums... hold on.

Admin
09-01-2001, 11:39 AM
Sorry, here it is: :)
$invposts=$DB_site->query_first("SELECT replycount FROM forum WHERE forumid=29");
$invthreads=$DB_site->query_first("SELECT count(*) AS threadcount FROM thread WHERE forumid=66 OR forumid=23 OR forumid=36 OR forumid=27 OR forumid=25 OR forumid=21 OR forumid=24 OR forumid=87");

webhost
09-01-2001, 11:54 AM
Thanks that did it I'm sure you probably have something better to do with your time.

Question later on if I wanted to do this again on another forum. Would I just put the same lines again in index.php but change
$invposts and $invthreads to something like $inv1posts and $inv1threads ?

Thanks again
Joey

Admin
09-01-2001, 12:07 PM
Yeah, and don't forget the new IDs. :)

[QUOTE]Originally posted by webhost
Thanks that did it I'm sure you probably have something better to do with your time.

webhost
09-05-2001, 08:30 PM
Firefly
Questions

First the thread count works great but for some reason when I update my counters it wipes out 70% of the threads in this forum.

Second where I installed this post and thread count on my forum, Is there away also I could add some code in the forumhome template along with what I have made already to show the last post not in each sub forum but only the last post in that group of sub forums?
Joey

Admin
09-06-2001, 10:50 AM
// dates for subs
$hiddenforum=$DB_site->query_first("SELECT lastpost FROM forum WHERE forumid=1 OR forumid=2 ORDER BY lastpost DESC LIMIT 1");
if ($hiddenforum['lastpost']>0) {
$hiddenforum['lastpostdate']=vbdate($dateformat,$hiddenforum['lastpost']);
$hiddenforum['lastposttime']=vbdate($timeformat,$hiddenforum['lastpost']);
} else {
$hiddenforum['lastpostdate']='Never';
$hiddenforum['lastposttime']='';
}
I think that should work. (replace the forumids of course)
Use $hiddenforum[lastpostdate] and $hiddenforum[lastposttime].

webhost
09-06-2001, 12:51 PM
Database error in vBulletin: Invalid SQL: SELECT lastpost FROM forum WHERE forumid=87 OR forumid=24 OR forumid=23 OR forumid=36 OR forumid=27 OR forumid=21 forumid=25 ORDER BY lastpost DESC LIMIT 1
mysql error:
mysql error number:
Date: Thursday 06th of September 2001 07:46:28 AM
Script: /
Referer:
This is where I placed in index.php

$boardviews = $DB_site->query_first("
SELECT SUM(views) AS threadviews FROM thread");
$totalviews = number_format($boardviews[threadviews]);

$invposts=$DB_site->query_first("SELECT replycount FROM forum WHERE forumid=29");
$invthreads=$DB_site->query_first("SELECT count(*) AS threadcount FROM thread WHERE forumid=66 OR forumid=23 OR forumid=36 OR forumid=27 OR forumid=25 OR forumid=21 OR forumid=24 OR forumid=87");

// dates for subs
$hiddenforum=$DB_site->query_first("SELECT lastpost FROM forum WHERE forumid=87 OR forumid=24 OR forumid=23 OR forumid=36 OR forumid=27 OR forumid=21 forumid=25 ORDER BY lastpost DESC LIMIT 1");
if ($hiddenforum['lastpost']>0) {
$hiddenforum['lastpostdate']=vbdate($dateformat,$hiddenforum['lastpost']);
$hiddenforum['lastposttime']=vbdate($timeformat,$hiddenforum['lastpost']);
} else {
$hiddenforum['lastpostdate']='Never';
$hiddenforum['lastposttime']='';
}

// get newest member
$getnewestusers=$DB_site->query_first("SELECT userid,username FROM user WHERE userid=$numbersmembers[max]");
$newusername=$getnewestusers['username'];
$newuserid=$getnewestusers['userid'];

Admin
09-06-2001, 01:08 PM
$hiddenforum=$DB_site->query_first("SELECT lastpost FROM forum WHERE forumid=87 OR forumid=24 OR forumid=23 OR forumid=36 OR forumid=27 OR forumid=21 forumid=25 ORDER BY lastpost DESC LIMIT 1");
So what happened to that OR before forumid=25? ;)

webhost
09-06-2001, 03:06 PM
Yes you are correct. I wasn't watching.

It works great, Thanks

Admin
09-06-2001, 03:11 PM
No problem. :)

Bitmap
11-20-2001, 02:57 PM
is this a released hack? because i couln't find it over there. and does this hack work with 2.2.0?
i really could need something like that.

Shakron
11-23-2001, 07:28 PM
Does it work with 2.2.1? *crosses fingers*

webhost
11-25-2001, 11:07 AM
It works on my 2.2.1

Bald Bouncer
11-25-2001, 02:23 PM
this works great on 2.2.0....cheers
can I add another one that just shows the amount made by the member?

Bitmap
11-25-2001, 05:08 PM
thanks :)

Bitmap
11-26-2001, 12:02 AM
hmm is there a way to make this work with several forums and there subforum? or does this only work with one?