Статистика за последните теми

h4x0r

Registered
Как мога да направя следното:

Форума ми е пхпбб3 и искам да направя така че над темите , над целия форум да ми изкарва коя е последната тема кой е узера с най-много коментари и така.. (една малка статистика)Бях го видял в един форум преди време но не съм сигурен дали беше пхпбб3 (не си спомням)
 
Не съм сигорен, че ще стане но пробвай така.

Копирай кода, направи нужните промени, запиши като .php файл, качи го на твоя сървър (където се намира форума), използвай <? include('filename.php'); ?> където искаш да се покаже (промени filename.php на истинското име на файла).


Код:
<?
#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>";
?>
 

Back
Горе