PDA

View Full Version : [PHPBB] Displaying user statistics on Non-phpBB Page



admans
07-18-2005, 18:28 PM
Step 1: Creating the userstats
The first step is to create a php file. Call the file userstats.php. Paste the following into the file. Make the neccesary changed


<?
#database info, or include a config.php file
$db_host = 'localhost';
$db_user = 'username'; #change to your databaseuser name
$db_password = 'password'; #change to your database password
$db_name = 'database_name'; #change to your db name #connect to the database, or end all scripts and give the reason for ending

mysql_connect($db_host,$db_user,$db_password) or die(mysql_error());
mysql_select_db($db_name) or die(mysql_error());

#select the number of users online
$result = mysql_query("SELECT count(s.session_logged_in)
FROM phpbb_sessions s
WHERE s.session_logged_in = 1");

#display amount of users online
echo "<table><tr><td>";
#this is a while loop that will loop through the array of returned
#results and display them, it is used throughout this script
while($r=mysql_fetch_array($result)){
echo "Total users online: ".$r['count(s.session_logged_in)']."<br>";
}

#select the newest member
$result = mysql_query("SELECT u.user_id, u.username
FROM phpbb_users u
ORDER BY u.user_id DESC
LIMIT 1");

#display newest user, change the <a> tag to your forum directory
while($r=mysql_fetch_array($result)){
echo "Newest registerd user: <a href=\"www.domain.com/forum/profile.php?mode=viewprofile&u=".$r['user_id']."\">".$r['username']."</a><p>";
}

#select total topics
$result = mysql_query("SELECT count(t.topic_id)
FROM phpbb_topics t");

#display total topics
while($r=mysql_fetch_array($result)){
echo "Total topics: ".$r['count(t.topic_id)']."<br>";
}

#select total amount of posts
$result = mysql_query("SELECT count(p.post_id)
FROM phpbb_posts p");

#display total posts
while($r=mysql_fetch_array($result)){
echo "Total Posts: ".$r['count(p.post_id)']."";
}
echo "</td></tr></table>";
?>


Step 2: Including the user stats
The next step is to include the stats into another file. First, you must make sure that the extension of the file you are going to include the user stats in is .PHP. If the extension is something else, change it to .PHP now. In order to include the stats, paste the following code to where you want the stats to be displayed


<? include('userstats.php'); ?>

xyris
07-19-2005, 07:01 AM
Is there some tooltip for vb to do this?