Count script.

Register an Account
Pligg Chat Room
Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-07-2006, 06:43 PM
New Pligger
 
Join Date: Feb 2006
Posts: 12
Counts how many users, and stories that are submited to your site.

1st step, make a count.php and put the following simple code:

PHP Code:
<?php
// Count script by LG-2. Gets the rows in MySQL and outputs them.
mysql_select_db($db);
$result mysql_query"SELECT * FROM users" )
or die(
"SELECT Error: ".mysql_error());
$num_rows mysql_num_rows($result);
$result2 mysql_query"SELECT link_id FROM links" )
or die(
"SELECT Error: ".mysql_error());
$num_links mysql_num_rows($result2);
?>
Open libs/html1.php and after all the comments add:

PHP Code:
include('count.php'); 
.

Now 3rd step I feel bad about but I havent messed with smarty much so I haven't been able to add it to smarty.

Open index.php and look where you want to put the code to output the number. I know this is going to be a little complicated but here's an example of how I did it:

PHP Code:
    echo '<center><table width="90%" height="20" border="0" cellspacing="0" cellpadding="0" bgcolor="#f1f1f1">
                                          <tr>
                                            <td width="2%" valign="top"><img src="/images/newscorner3.gif" width="20" height="20" /></td>
                                            <td width="96%"><div align="center"><font class="h5red"><a href=shakeit.php>Buscar Otras Noticias</a> / <a href=submit.php>Zumba una Noticia!</a> / </font></right><font class="thiscat"><strong><a href="topusers.php">Usuarios registrados:</a> </strong></font>'

                                            echo 
"<font class=h5red>$num_rows / </font> ";
                                            echo 
'<font class="thiscat"><strong><a href="topstories.php">Historias Publicadas:</a> </strong></font>';
                                            echo 
"<font class=h5red>$num_links</font>";

                                            echo 
'</td><td width="2%" valign="top"><img src="/images/newscorner4.gif" width="20" height="20" /></td>
                                          </tr>
                                        </table></center><p><font class="thiscat">* Estas noticias son publicadas por los usuarios.<br> 
* Cualquier pregunta o para reportar un error (bug), por favor enviale un email a LG-2 <a href="mailto:lg2@zumbalo.com">(lg2@zumbalo.com)</a>.</font><br>
<font class="h5red"><a href="tuts.php">Aprende a usar esta pagina!</a></font><p>'

$num_rows is the variable for the user count.
$num_links is the variable for the stories count.

Now the stories might display a bigger number than the stories that actually appear and that is because it also count the discarted stories. Is also good to run the meneame.net script.

Last edited by LG-2; 03-07-2006 at 06:47 PM.
Reply With Quote
  #2 (permalink)  
Old 03-07-2006, 11:45 PM
Constant Pligger
 
Join Date: Jan 2006
Posts: 189
LG-2, wonderful! thanks for sharing
Reply With Quote
  #3 (permalink)  
Old 03-08-2006, 03:40 PM
New Pligger
 
Join Date: Feb 2006
Posts: 12
Thanks jejeje no prob. :-D. More to come soon!
Reply With Quote
  #4 (permalink)  
Old 03-21-2006, 02:16 PM
New Pligger
 
Join Date: Mar 2006
Posts: 7
What version of pligg did you add this code too because I am using 6 and I am trying to find out where you can post this snippit of code.
Reply With Quote
  #5 (permalink)  
Old 03-26-2006, 07:34 PM
New Pligger
 
Join Date: Feb 2006
Posts: 12
Quote:
Originally Posted by new_start
What version of pligg did you add this code too because I am using 6 and I am trying to find out where you can post this snippit of code.
Its version 6 but my Pligg has been edited alot... but you can add it to the footer after print_summary
Reply With Quote
  #6 (permalink)  
Old 10-09-2006, 12:19 AM
New Pligger
 
Join Date: May 2006
Posts: 29
this is an update to LG's script
just gives the users alot more information than just total members and links...

it also gives a total for comments, categories, pageviews, tags and votes!


--------------------------------

1st step, make a count.php and put the following simple code:

PHP Code:
<?php
// Count script by LG-2. Gets the rows in MySQL and outputs them.
mysql_select_db($db);
$result mysql_query"SELECT * FROM users" )
or die(
"SELECT Error: ".mysql_error());
$num_rows mysql_num_rows($result);
$result2 mysql_query"SELECT link_id FROM links" )
or die(
"SELECT Error: ".mysql_error());
$num_links mysql_num_rows($result2);
$result3 mysql_query"SELECT comment_id FROM comments" )
or die(
"SELECT Error: ".mysql_error());
$num_comments mysql_num_rows($result3);
$result4 mysql_query"SELECT category__auto_id FROM categories" )
or die(
"SELECT Error: ".mysql_error());
$num_categories mysql_num_rows($result4);
$result5 mysql_query"SELECT pv_id FROM pageviews" )
or die(
"SELECT Error: ".mysql_error());
$num_pageviews mysql_num_rows($result5);
$result6 mysql_query"SELECT tag_link_id FROM tags" )
or die(
"SELECT Error: ".mysql_error());
$num_tags mysql_num_rows($result6);
$result7 mysql_query"SELECT vote_id FROM votes" )
or die(
"SELECT Error: ".mysql_error());
$num_votes mysql_num_rows($result7);
?>

2nd step is to place this somewere on your site (of course change the text to fit your personal site)
I myself put it in libs/sidebarstories.php...

PHP Code:
include('count.php'); 

            echo 
" TVB Members: <font class=h5red>$num_rows  </font> <br>";
            echo 
"TVB Videos: <font class=h5red>$num_links</font><br>";
            echo 
"TVB Votes: <font class=h5red>$num_votes</font><br>";
            echo 
"TVB Comments: <font class=h5red>$num_comments</font><br>";
            echo 
"TVB Categories: <font class=h5red>$num_categories</font><br>";
            echo 
"TVB Tags: <font class=h5red>$num_tags</font><br>";
            echo 
"TVB Page Views: <font class=h5red>$num_pageviews</font>"
just wanted to share this update with the community
thatvideoblog.com
Reply With Quote
  #7 (permalink)  
Old 10-10-2006, 02:19 AM
kbeeveer46's Avatar
Pligg Developer/Admin
Pligg Version: 0
Pligg Template: none
 
Join Date: Jun 2006
Location: Muncie, Indiana
Posts: 3,215
Thanks a lot. We will definately add this to Pligg somehow.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Mod] Category Count - Final Geoserv Questions and Comments 25 01-31-2010 05:15 PM
vote count and voters mahi_siah Questions and Comments 2 05-31-2008 02:24 AM
Internal Server Error cvcxl Questions and Comments 2 02-29-2008 06:51 PM
Premature end of script headers d4dirty Questions and Comments 3 01-03-2008 10:22 AM
Injecting values from Pligg into Google Script aaronpais Questions and Comments 4 06-02-2007 04:23 PM


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