Log in

View Full Version : How to show the amount of replies a thread has on a non-vB page?


Shaliza
10-11-2007, 11:57 AM
I want to use a forum for comments for my site instead of using a regular comments form. For example, if a thread has 10 replies, on the non-vB page, I'd like it to say 10 Comments. That's it. Nothing fancy

--------------- Added at 20:55 ---------------

Anyone? I need to get this done ASAP.

Shaliza
10-14-2007, 06:11 AM
Anyone?

Shaliza
10-16-2007, 01:20 AM
This is the last one.

RobDog888
10-16-2007, 03:01 AM
<font color="darkgreen">You will want to query the thread table and pull out the "views" field.

Ex.

SELECT t.views AS views FROM thread WHERE threadid = 12345

</font>

Shaliza
10-24-2007, 03:02 AM
How do I go about coding this onto my website exactly? Thanks for the help!

Kirk Y
10-24-2007, 03:30 AM
You will want to query the thread table and pull out the "views" field.

Ex.

SELECT t.views AS views FROM thread WHERE threadid = 12345


I think he wants replies.. not views. ;)

In any event, you'd want to include global.php on your external page and set the working dir. to your forum:
chdir('/path/to/your/forums');
require_once('/path/to/your/forums/global.php');Then just query the database like robdog mentioned, something like this:
$query = $db->query_first("SELECT * FROM thread WHERE threadid = 1234");Then you can use $query[replycount] to output the number of replies in thread 1234. Obviously this is just a basic example and needs expanded upon, but this should give you a general idea.

Keloran
10-24-2007, 12:29 PM
if you have your own db code, then simply

SELECT replycount FROM thread WHERE threadid = <threadid> LIMIT 1

NEVER DO SELECT * unless you want absolutlly everything from the thread, which 9/10 you WONT

Kirk Y
10-24-2007, 04:02 PM
Which is why I said "basic example"... he's going to want more than just the replycount field either way; at the least, he'll more than likely want the title and thread starter.

Shaliza
10-25-2007, 02:14 AM
I'm a girl!

Actually, all I want is for it to say 10 Comments if there are 10 replies, ect. I don't want anything else with it. And I'm not too crazy familiar with vB coding, so I will try...

What is that $query[replycount] bit about though?

Shaliza
11-24-2007, 01:19 PM
I have a problem. When I tried it, it said this on the site:

Fatal error: Call to a member function on a non-object

Shaliza
11-26-2007, 07:00 AM
Anyone?