The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Get threads with most replies in last two weeks?
Ok I asked on vb.com but no one anwers there so I thought you guys know ho to go about this!?
____________________ I'm writing a script on a page outside of vb. I want it to print the 20 latest threads from a few specific forums that has got most replies in the last two weeks. I'm currently in the learning state of MySQL and I think this could be a quite easy query for you pros. Appreciate any effort to help, here's what I got so far PHP Code:
Nvm I SELECT so many columns, I need them for something else. Thanks! |
#2
|
||||
|
||||
hmm this query should generally work:
[sql] SELECT thread.* FROM post INNER JOIN thread USING (threadid) WHERE thread.forumid IN (xx,yy,zz) AND post.dateline >= $twoweeks GROUP BY post.threadid ORDER BY replycount DESC LIMIT 20[/sql] |
#3
|
||||
|
||||
Thanks a lot for your help, it's almost what I want!
But when I use "ORDER BY replycount", the threads with VERY many posts show up in the top of the list, even though they haven't got the most new replies within the last two weeks. It seems like threads (which has many replies) get onto this list that has only got a FEW new posts in the last two weeks but is put in the top because of their high replycount. I hope you understand what I'm trying to say here!? Again thanks for helping! |
#4
|
||||
|
||||
ah, i see what you mean!
hmm, try that one instead: [sql]SELECT count(post.postid) AS newpostcount, thread.* FROM post INNER JOIN thread USING (threadid) WHERE thread.forumid IN (xx,yy,zz) AND post.dateline >= $twoweeks GROUP BY post.threadid ORDER BY newpostcount DESC LIMIT 20[/sql] |
#5
|
||||
|
||||
Thanks Xenon, it works perfect.
Just on a side note, I'm also pulling out a line of text from the first post in each thread to display, I know how to do it but is there anyway to remove all words that begin with [ ? cause right now it looks like a mess if someone for example has written "[Font color=Blue]Hey this is my thread and I use this color for all the text[/font]". Also when the post is beginning with an image "[img]http://sjfiojdsifsopf.fsdfjsifjosdjfisdf.dfsd.gif[/ img]" this problem occurs. Any help how to just remove the stuff inside of BB [] brackets would be greatly appreciated, I've tried numerous different ways but haven't come up with any that works! Thanks again! Nevermind, I figured it out myself! Thanks for all help! |
#6
|
||||
|
||||
strip_bbcode? ^^
|
#7
|
||||
|
||||
I didn't even know there was a function called strip_bbcode, instead I used preg_replace("/\[.*?]/s", "", $firstpost).
It's good because it wont remove what's inside the bb codes, for example if someone writes something in bold, it's still there. |
#8
|
||||
|
||||
erm, isn't that what strip_bbcode is supposed to do?
don't mix it up with strip_quote |
#9
|
||||
|
||||
Ah I really dunno man, all I know is that it works as it should!
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|