PDA

View Full Version : Thread Reply Count on NONvb page


Fuzz
05-09-2005, 07:48 PM
Hey all,

I have searched and searched these forums for a solution to no avail. Hopefully someone can help me. I don't think it is a hard mod and I feel like I'm close because I know PHP to a small extent.

I just want to post the reply count of a desingated thread. For instance, I would have a news story on my front page and then have a simple phrase at the bottom that would link the user to that news article (thread xxxx) on the forums and then also show a reply count. So is there an easy way to do this? something like this:

$replycount = "SELECT replycount FROM thread WHERE threadid = 715925";

Obviously, I know the above statement is wrong, but it gives a better clarification on what I need. Any help would be much appreciated. Thanks in advance.

(I'm running VB 3.0.7)

steve

Fuzz
05-10-2005, 08:46 PM
I have been playing with this for hours now, still not luck. Can anyone please give me a knock in the right direction. This is the code I'm using now, but I"m still getting nothing to display. Please help



require_once("./global.php");

$threadWanted = 715925;
$replies = $DB_site->query_first("SELECT replycount FROM " . TABLE_PREFIX . "thread WHERE threadid = " . intval($threadWanted));

echo "$replies['replycount']";

cinq
05-11-2005, 12:04 AM
require_once("./global.php");
$replies = $DB_site->query_first("SELECT replycount FROM " . TABLE_PREFIX . "thread WHERE threadid = 715925 ");
echo $replies['replycount'];

?

Fuzz
05-11-2005, 12:38 AM
Thanks for the reply Cing -

Unfortunately, I tried your code and I'm still getting nothing. I just recieve a blank page, no errors, just a blank page.

I'm still playing around with the code. It seems so easy, but it remains so hard. If you get any alternative ideas, please share them. I'm still in a rut. \=(

cinq
05-11-2005, 12:44 AM
What does running this


SELECT replycount FROM thread WHERE threadid = 715925


in phpMyAdmin give you ?

Link14716
05-11-2005, 01:50 AM
I have been playing with this for hours now, still not luck. Can anyone please give me a knock in the right direction. This is the code I'm using now, but I"m still getting nothing to display. Please help



require_once("./global.php");

$threadWanted = 715925;
$replies = $DB_site->query_first("SELECT replycount FROM " . TABLE_PREFIX . "thread WHERE threadid = " . intval($threadWanted));

echo "$replies['replycount']";

You'll get a parse error on this code:

echo "$replies['replycount']";
Use either this:
echo "$replies[replycount]";
or this (prefered):
echo $replies['replycount'];

Fuzz
05-11-2005, 05:42 AM
Thanks again for the quick replies, much appreciated...

What does running this


SELECT replycount FROM thread WHERE threadid = 715925


in phpMyAdmin give you ?

It executed, but I didn't get a # result... this is what is spit out...


Your SQL-query has been executed successfully (Query took 0.0002 sec)
SQL-query:
SELECT replycount
FROM thread
WHERE threadid =715925
LIMIT 0 , 30


So I'm guessing that is why I am getting a blank page still when I run my above script on a .php file... b/c no actual number is being outputted... I'm sure there is just a missing variable I'm forgetting to include.


Link - Thanks for the reply. Unfortunately I tried your corrections and still get a blank page. Not sure what the problem is but thanks for the effort. I'm not getting any parse errors or anything, just a blank page.

cinq
05-11-2005, 05:44 AM
There you go, the sql query returned 0 results in the first place, which is why echo $replies['replycount']; gives you nothing.

Are you sure there is a thread with threadid 715925 present ? Seems like an awefully large number, you must have a huge board :D

[edit] : ok checked your site ( assuming this is the site you are using the code for ).
Seems this thread id is not valid, could have been a deleted thread :
http://www.thefinalfantasy.com/forums/showthread.php?t=715925

Fuzz
05-11-2005, 08:45 AM
There you go, the sql query returned 0 results in the first place, which is why echo $replies['replycount']; gives you nothing.

Are you sure there is a thread with threadid 715925 present ? Seems like an awefully large number, you must have a huge board :D

[edit] : ok checked your site ( assuming this is the site you are using the code for ).
Seems this thread id is not valid, could have been a deleted thread :
http://www.thefinalfantasy.com/forums/showthread.php?t=715925


For some reason if you change that .php?t to a .php?p, the URL will work... odd, but hey, the SQL query still wont work even if I try threadid that i KNOW exist. One interesting I just found was when I went to EXPLAIN query, I got this message:

Impossible WHERE noticed after reading const table...

Maybe we are declaring the const. table wrong, it makes no sense though... everything appears to be fine in the query. ugh

Thanks again for your ongoing help man, I feel like I"m getting real close to a solution

Marco van Herwaarden
05-12-2005, 04:49 AM
Just 1 advice, try your query first in phpMySQL and when it works like expected, copy it to your script.