[SOLVED] Top 5 users in sidebar

Register an Account
Reply
 
Thread Tools Display Modes
  #11 (permalink)  
Old 07-03-2007, 12:06 PM
Constant Pligger
 
Join Date: Apr 2007
Posts: 1,042
Quote:
Originally Posted by dollars5 View Post
are any comments posted in the Pligg setup.
You mean if I already have comments in my installed instance of Pligg? Yes, more than latest comments could show. :-)

I just thought about testing the query with phpMyAdmin:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '" . "table_comments" . ". , " . table_users . " WHERE comment_user_id=user_id GR' at line 1

Do you know what that could mean related to MySQL version 5.0.32?

BTW: Iīm using v9.5.
Reply With Quote
  #12 (permalink)  
Old 07-03-2007, 02:55 PM
Constant Pligger
 
Join Date: Apr 2007
Posts: 1,042
I´ve learned that MySQL v5 has the most powerful implementation of SQL to date so if it worked on dollar5´s DB it should work also on mine in theory.
Reply With Quote
  #13 (permalink)  
Old 07-03-2007, 08:59 PM
dollars5's Avatar
Pligg Donor
 
Join Date: Dec 2006
Location: India
Posts: 1,960
table_comments and table_users are your corresponding database table names - they will work only when initialized properly in /libs/define_tables.php

if you are to try the query directly - then you will have to try something like this
Code:
SELECT user_login, count(*) as count FROM Pligg_comments , Pligg_users WHERE comment_user_id=user_id GROUP BY comment_user_id ORDER BY count DESC
again replace the "Pligg_" with your db table prefix - else you will still keep getting the same error from your query viewer.

I agree mySQL is great, but user mistakes are not. I posted the queries and statement for the tpl - only after I have tested them (if you look from my past posts - if I am to post untested query/code - I will let the users know of it)

It would be great to share the file that you are playing with to give more idea rather than just presenting the error messages.
Reply With Quote
  #14 (permalink)  
Old 07-04-2007, 04:49 AM
Constant Pligger
 
Join Date: Apr 2007
Posts: 1,042
Quote:
Originally Posted by dollars5 View Post
table_comments and table_users are your corresponding database table names - they will work only when initialized properly in /libs/define_tables.php

if you are to try the query directly - then you will have to try something like this
Code:
SELECT user_login, count(*) as count FROM Pligg_comments , Pligg_users WHERE comment_user_id=user_id GROUP BY comment_user_id ORDER BY count DESC
again replace the "Pligg_" with your db table prefix - else you will still keep getting the same error from your query viewer.
Ah, these names are Pligg-own aliases. I havenīt changed the db prefix so I tried with pligg_ and it works perfect, thank you. Maybe there is a bug in define_tables.php of v9.5.

Quote:
Originally Posted by dollars5 View Post
I agree mySQL is great, but user mistakes are not. I posted the queries and statement for the tpl - only after I have tested them (if you look from my past posts - if I am to post untested query/code - I will let the users know of it)

It would be great to share the file that you are playing with to give more idea rather than just presenting the error messages.
Sorry, it was not my intention to annoy you in any way. Iīve never questioned your query. All I wanted to say was if I have newest version of MySQL you can have have only the same or an older one so if it worked with your db it has to work with mine. I didnīt post the file because it contains just the code at the top of the thread. Once again, I really appreciate your help!

P.S.: Do you have any idea what could be the probem here (http://forums.pligg.com/pligg-mods/7...ar-module.html) ?
Reply With Quote
  #15 (permalink)  
Old 07-04-2007, 05:24 AM
dollars5's Avatar
Pligg Donor
 
Join Date: Dec 2006
Location: India
Posts: 1,960
Oh, I meant it in a manner that the query was buggy - np.

If you could provide me the file that you are facing problems with the top users by comments - I can investigate and get it work.
Reply With Quote
  #16 (permalink)  
Old 07-04-2007, 05:45 AM
Constant Pligger
 
Join Date: Apr 2007
Posts: 1,042
Quote:
Originally Posted by dollars5 View Post
If you could provide me the file that you are facing problems with the top users by comments - I can investigate and get it work.
Quote:
Originally Posted by tbones View Post
I havenīt changed the db prefix so I tried with pligg_ and it works perfect, thank you.
Sorry, English is not my mother tongue. Could you tell me how to display the amount of comments like "<avatar> dollar5 (20)" ?
Reply With Quote
  #17 (permalink)  
Old 07-06-2007, 08:00 PM
Constant Pligger
 
Join Date: Apr 2007
Posts: 1,042
Do I have to define a variable to show the number of comments?
Reply With Quote
  #18 (permalink)  
Old 07-07-2007, 12:55 AM
dollars5's Avatar
Pligg Donor
 
Join Date: Dec 2006
Location: India
Posts: 1,960
The query will return both the user id and comments count - so just you can use it as $row['count'];
Reply With Quote
  #19 (permalink)  
Old 07-07-2007, 01:55 AM
Constant Pligger
 
Join Date: Apr 2007
Posts: 1,042
Sorry for bothering you once again but syntax is sadly not my field of expertise!

To avoid any misunderstandings, here is the full code that doesnīt work:

Code:
{if $user_logged_in neq ""}

<div class="tlb">
<a href="topusers.php"><strong>Top commenters</strong></a></div>
<div style="padding-top:5px;padding-bottom:1px">
	<ul style="list-style:none;">
		{php}
			global $db;
			$sql="SELECT user_login, count(*) as count FROM pligg_comments , pligg_users WHERE comment_user_id=user_id GROUP BY comment_user_id ORDER BY count DESC limit 0,3";
			$result = @mysql_query ($sql);
			$rowCount = 0;
			while($row = mysql_fetch_array($result, MYSQL_ASSOC))
			{
				$uname=$row['user_login'];
				if (($rowCount++)%2 == 0)
					echo "<li><span class='feature-back'><img src='". get_avatar('large', "", "$uname","","")."' class='align-middle'>&nbsp;<a href='" . getmyurl('user2', $uname, 'profile') . "'>$uname &nbsp; $row['count']</a></span></li>";
				else
					echo "<li><img src='". get_avatar('large', "", "$uname","","")."' class='align-middle'>&nbsp;<a href='" . getmyurl('user2', $uname, 'profile') . "'>$uname</a></li>";
			}
		{/php}
	</ul>
</div>
{/if}
I will adapt the else-branch if the then-branch works.
Reply With Quote
  #20 (permalink)  
Old 07-07-2007, 02:25 AM
dollars5's Avatar
Pligg Donor
 
Join Date: Dec 2006
Location: India
Posts: 1,960
this works fine for me, btw: did not check your code:
Code:
echo "<li><img src='". get_avatar('large', "", $uname,"","")."'> &nbsp; <a href='" . getmyurl('user2', $uname, 'profile') . "'>$uname</a> &nbsp;". $row['count'] ."</li>";
EDIT:
see it live at Pligg Beta 9 / Published News

Last edited by dollars5; 07-07-2007 at 02:34 AM.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Display User's Saved Stories in Sidebar timofsuburbia Questions and Comments 3 06-08-2010 02:19 PM
The sidebar disappeared for logged in users yobeta Questions and Comments 1 09-12-2008 03:10 AM
Sidebar Top Users netfreak Questions and Comments 2 05-25-2008 09:49 AM
[SOLVED] Add Lins in sidebar? Luke Beale Questions and Comments 7 07-11-2007 12:21 AM
[SOLVED] Redirect to user's page after submit revolver Questions and Comments 2 07-06-2007 11:24 AM


Pligg Modules and Pligg Templates from Pligg Pro Find support on the Pligg CMS Forum - 24 hours a day! Make a donation to support Pligg CMS development