Log in

View Full Version : How to display the number of posts on a thread to your homepage


The slime
07-04-2014, 06:15 PM
Is this possible ? Example a thread named "A" has 6 posts . Can I have 6 display on my home page ? Any help is much appreciated.

Lynne
07-04-2014, 06:21 PM
Is your homepage some custom coded page? Do you have a link to show us this on someone else's site or else an image to explain what you want?

The slime
07-05-2014, 01:46 AM
No however I have seen it . Mostly for positive and negative comments of a company . So in the forum it would have a "positive thread " and a "negative" thread . So let's say 5 people posted under the positive thread and 2 people posted on the negative thread .
On the home page it would show positive (5) negative (2) for the company .

Lynne
07-05-2014, 03:09 PM
You can just do a query on the thread table to get the number of posts in that thread - thread.replycount.

Simon Lloyd
07-05-2014, 05:15 PM
No however I have seen it . Mostly for positive and negative comments of a company . So in the forum it would have a "positive thread " and a "negative" thread . So let's say 5 people posted under the positive thread and 2 people posted on the negative thread .
On the home page it would show positive (5) negative (2) for the company .What do you mean "Home page"? forumhome or forumdisplay?

The slime
07-05-2014, 06:08 PM
A non forum php page .

Lynne
07-05-2014, 09:34 PM
Then yes, you may just query the vbulletin database to get the number of replies and then put that information on your page.

The slime
07-05-2014, 09:47 PM
Thanks Lynne for your time . I usterstand how to query the database . I just dont know what php code to put at my homepage to get fetch this info .

Lynne
07-06-2014, 01:21 AM
Well, I don't know how you have written your queries in the home page, so I really can't help you with the exact code. All I can tell you is that you want to get thread.replycount WHERE thread.threadid = the id of the thread you want.

The slime
07-06-2014, 02:37 PM
this is the php in mysql
$sql = "SELECT replycount FROM thread WHERE threadid = 84\n"
. " LIMIT 0, 30 ";

I just want it the reply # to populate on my blank .php test page .

here is my query
SELECT replycount FROM thread WHERE threadid = 84

Lynne
07-06-2014, 03:30 PM
The query looks just fine (except why do you use LIMIT - you should only be getting one row). After you do the select, you need to do a mysql_fetch_array to get the actual data.

The slime
07-10-2014, 02:57 PM
Thanks Lynn for your help I did get it working . I was getting a error and it was driving me nuts . I was using ' instead of ` in parts of the code. So that lead to me thinking the problem was something else. lol

Lynne
07-10-2014, 03:48 PM
Glad you got it working.