Script to display the last message on the forums phpbb3
Posted: Wed Aug 01, 2012 4:08 pm
Made a PHP script to display the last message on the forums phpbb3. No messing around with mods - code, which I quote, save "recent.php"and throw in the main folder of the forum. When you open a file "recent.php" displays a list of links on the latest topics. Can someone be useful. Here is the code:
If you have any questions about the code - write, explain.
Code: Select all
<?php
$Database = @mysql_connect("localhost","admin");
if ($Database == false) {
die("<span style = 'text-align: center; color: red; font-family: Arial; font-size: 11pt;'>Не удалось подключиться к базе данных</span>");
}
else {
@mysql_select_db("phpbb", $Database) or die("<span style = 'text-align: center; color: red; font-family: Arial; font-size: 11pt;'>Не удалось выбрать таблицу</span>");
$query = "SELECT topic_id, forum_id, topic_title, topic_time FROM phpbb_topics ORDER BY topic_time DESC LIMIT 0 , 30";
$result = mysql_query($query);
if ($result) {
$count = mysql_num_rows($result);
$link = "";
for ($i = 0; $i < $count; $i++)
{
$forum_id = mysql_result($result,$i,"forum_id");
$topic_id = mysql_result($result,$i,"topic_id");
$topic_title = mysql_result($result,$i,"topic_title");
settype($topic_id,"string");
settype($forum_id,"string");
$link .= "<a href = 'viewtopic.php?f=";
$link .= $forum_id;
$link .= "&t=";
$link .= $topic_id;
$link .= "'>";
$link .= $topic_title;
$link .= "</a><br>";
}
echo "<html>\n<head></head>\n<body>";
echo $link;
echo "</body>\n</html>";
}
else {
die("<span style = 'text-align: center; color: red; font-family: Arial; font-size: 11pt;'>Не удалось выполнить запрос" . mysql_error()."</span>");
}
}
?>