Copy this code, make the neccessary changes, save as a .php file, upload to your
server, and use <? include('filename.php'); ?> where ever you want it to
show up (change filename.php to the files acctual name).
If you have any questions, just ask on the
tutorial help forums.
<?
#database info, or include a config.php file
$db_host = 'localhost'; #change to your host
$db_user = 'username'; #change to your user name
$db_password = 'password'; #change to your 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)){
# Change http://www.domain.com/forum either the path to your forum, or a direct link to the forum if it's on a sub-domain */
echo "Newest registerd user: <a href=\"http://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>";
?>