boardom Forum Index boardom
b2 message board
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

b2 stats help--SQL query question

 
Post new topic   Reply to topic    boardom Forum Index -> Hacks
View previous topic :: View next topic  
Author Message
xtheunderdog



Joined: 15 Jun 2004
Posts: 10

PostPosted: Wed Oct 27, 2004 11:52 pm    Post subject: b2 stats help--SQL query question Reply with quote

So, I'm trying to get b2stats to list the top five authors on my b2 blog, and i'm almost there, but, it lists the author id instead of their login name like i want. i can't figure out how to get it to call user_login from tableusers and then order it by calling the_author from tableposts. I've tried a ton of different things, but they all result in errors-- this is the only thing that hasn't, and it's not calling any of the other tables.

This is what I have right now:
Code:
$ams = "SELECT post_author, COUNT(*) AS 'total' FROM $tableposts GROUP BY post_author ORDER BY total DESC LIMIT 5";
Back to top
View user's profile Send private message
xtheunderdog



Joined: 15 Jun 2004
Posts: 10

PostPosted: Thu Oct 28, 2004 5:03 am    Post subject: Reply with quote

also, what would i do to fetch how many comments and posts are being made a day.

for instance, there were 49 comments made today on my b2...i want to get the stats to say that, and then keep counting todays and then come tomorrow start over the count again, but i can't quite figure that out either.
Back to top
View user's profile Send private message
Cyberian75



Joined: 26 Sep 2002
Posts: 1285
Location: Oregon

PostPosted: Sat Oct 30, 2004 4:51 am    Post subject: Reply with quote

http://www.cafelog.com/board/viewtopic.php?t=2125
_________________
Michael P.

Back to top
View user's profile Send private message AIM Address
Cyberian75



Joined: 26 Sep 2002
Posts: 1285
Location: Oregon

PostPosted: Sat Oct 30, 2004 4:59 am    Post subject: Re: b2 stats help--SQL query question Reply with quote

xtheunderdog wrote:
This is what I have right now:
Code:
$ams = "SELECT post_author, COUNT(*) AS 'total' FROM $tableposts GROUP BY post_author ORDER BY total DESC LIMIT 5";


HINT: Use the WHERE clause with author names, or you'd do a JOIN with comments and users tables.
_________________
Michael P.

Back to top
View user's profile Send private message AIM Address
Cyberian75



Joined: 26 Sep 2002
Posts: 1285
Location: Oregon

PostPosted: Sat Oct 30, 2004 5:09 am    Post subject: Reply with quote

xtheunderdog wrote:
also, what would i do to fetch how many comments and posts are being made a day.

for instance, there were 49 comments made today on my b2...i want to get the stats to say that, and then keep counting todays and then come tomorrow start over the count again, but i can't quite figure that out either.


Code:

SELECT...WHERE YEAR(N0W()) = YEAR(post_date) AND MONTH(N0W()) = MONTH(post_date) AND DAYOFMONTH(N0W()) = DAYOFMONTH(post_date) ...


Something like that. Smile

http://dev.mysql.com/doc/mysql/en/index.html
_________________
Michael P.

Back to top
View user's profile Send private message AIM Address
Sigg3



Joined: 03 Jul 2003
Posts: 906
Location: Oslo, Norway

PostPosted: Sun Oct 31, 2004 12:05 am    Post subject: Reply with quote

Anyone have a zipfile with the b2ministats hack?
My source went down before I had the chance to mirror it...
_________________
Sigg3.net - You know you're worth it! | b2 Cafelog Resource Center | Fight my BattleImp!
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    boardom Forum Index -> Hacks All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2 © 2001, 2002 phpBB Group