![]() |
how I can post the total number of threads in a certain forum on a non-vb page??
|
Here is a start. I have no idea how to do the query. Can anyone help??
<?php // Set this to the Forum ID to display $forum = 20; require("forum/admin/config.php3"); $db=mysql_connect($servername,$dbusername,$dbpassw ord); mysql_select_db($dbname); $forumtitle=htmlspecialchars($forum[title]); $numberthreads=$forum[threadcount]; <A HREF="forumdisplay.php3?forumid=$forum">$forumtitl e</A> has $numberthreads Threads. ?> |
90 Views and no one wants to help...
|
It's not that we don't WANT to help, many of us don't know HOW to help.
|
Quote:
http://www.vbulletin.com/forum/showt...?threadid=2658 |
here's what the thread had further down
Code:
<?php |
Code:
$query = "select * from thread"; Code:
SELECT COUNT(*) FROM thread -Chris [Edited by Chris Schreiber on 09-08-2000 at 04:58 PM] |
chris i tried SELECT COUNT(*) FROM thread
and it displayed my total thread count = 1 ? |
Quote:
I can't check this now, but I will take a look at this later tonight.... this is valid SQL, I even checked here to make sure: http://www.mysql.com/documentation/m...=Counting_rows -Chris |
|
Um...
Wouldn't you just have to get the forumid, then just do something simple like. <?php $query = "select forumid from thread where forumid='theforumidyouchose'"; $result = mysql_query($query); $num_rows = mysql_num_rows($result); print "There are $num_rows results in that forum"; ?> Keep it simple, thats the way to do it I think. |
Quote:
Code:
$query=mysql_query("SELECT COUNT(threadid) AS totalthreads FROM thread"); Then you could just grab the total threads by doing something like: Code:
$row=mysql_fetch_array($query); ??? I didnt think of this the first time, because im not very knowledgable on server load / mysql strain.....etc... So i guess i really didnt care :D ~Chris |
<?php
require("forum/admin/config.php3"); $db=mysql_connect($servername,$dbusername,$dbpassw ord); mysql_select_db($dbname); $query=mysql_query("SELECT COUNT(threadid) AS totalthreads FROM thread"); $row=mysql_fetch_array($query); $totalthreads = $row[totalthreads]; echo "$totalthreads total threads"; ?> That code shows the total number of posts on the board, not in a specific forum. |
FORUM LIST W/ TOTAL THREADS ON NON VB PAGE
http://www.extremeforums.com/include..._count.inc.php Usage: Code:
include("/full/path/to/forumlist_with_count.inc.php"); Code:
<?php ~Chris |
Oh yeah,
In my one I left out the MySQL connect code. You'll have to connect to the MySQL and choose the database that vBulletin is in. |
Its killing me how a person can ask a question and people can take is so far off topic, and get so turned around
:mad: |
Quote:
Read this thread a little closer, im not even the one who posted that code |
Roger, I stand corrected. You were correcting someone elses code that had nothing to do with what i asked about in the first place :)
|
Quote:
~Chris |
Quote:
-Thomas |
Which forum? whats the id??? The above code could easily be modified to only show one
|
Quote:
|
Code:
<?php |
Whenever you need me to bow down and kiss your feet in public, let me know!! :cool:
|
Quote:
Code:
<?php http://www.extremeforums.com/include....php?forumid=2 ~Chris |
What was wrong with my code? It did exactly what you needed :)
|
:)
|
I think a little feet kissing is deserved ;)
Anyway - selecting all the the forumid's and then doing a myqsl_num_rows on it is going to be more accurate then selecting the threadcoutn thing, which is the main difference between the two versions. You are only selecting numbers as well, so even if you have alot of threads it isn't going to be server intensive. I like to try to make everything accurate, so I would do it that way :) |
Quote:
Just my $0.02 ~Chris |
But threadcount is incremented everytime something is posted, but if there was an error in MySQL and some information was deleted then threadcount would be inaccurate. If you wanted to delete a post through PhpMyAdmin then threadcount would be wrong.
Using a field that is incremented to keep count isn't very accurate. |
Quote:
Code:
<?php Easy. And works. [Edited by mrogish on 09-11-2000 at 01:22 AM] |
That way works as well - one of the books I have says that mysql_num_rows function isa better way, but what you have is better then using the threadcount field.
|
lol!
|
?
|
Quote:
1. count is a built in SQL function -- so it's far more efficent than selecting everything in the table. 2. Once you get a result you directly access the array $result[ somevar ]; rather than executing another function (mysql_num_rows( )) -- this would shave off some overhead on PHP's account I would believe. 3. That's what the count( ) function is supposed to do! :) 4. There is no number 4! But, all of the methods work, it's up to whomever wanted it in the first place to decide! :) |
Thanks guys... :)
|
I guess your right, cause SQL functions are faster then PHP functions.
|
All times are GMT. The time now is 02:00 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|