How to display some statistics on your homepage

Frequently Asked Questions (read only)

How to display some statistics on your homepage

Postby FI-DD » Thu Nov 24, 2005 8:52 pm

Put this function below the include of head.php in the page which shows your news.



Code: Select all
function stats() {

global $sql;



$stat = array('Users' => 'users', 'News' => 'news', 'Comments' => 'comments', 'Categories' => 'categories');



foreach ($stat as $name => $table) {

echo $name.": ".count($sql->select(array('table' => $table)))."<br>";

}

}




Then you can show the stats by calling the function: stats();



It will show you something like this:



Users: 1

News: 8

Comments: 4

Categories: 2
User avatar
FI-DD
Admin
 
Posts: 2971
Joined: Thu Sep 22, 2005 11:27 am
Location: Germany

Return to FAQ



Who is online

Users browsing this forum: No registered users and 0 guests

cron