A Major Recent Topics phpblock Fix :)
- Wednesday, July 10 2002 @ 04:22 pm EDT
- Contributed by: Anonymous
- Views: 5,254

HERES THE CODE :)
//TESTING
function phpblock_phpbb2recent() {
// You MUST copy the following 4 variables from your config.php file in your phpbb2 install
$dhhost = \"localhost\";
$dbname = \"phpBB\";
$dbuser = \"name\";
$dbpasswd = \"pass\";
$urlPath = \"http://yoursitehere/phpBB2\";
$PostNumber = \"5\";
$type = \"posts\";
$length = \"12\";
$db = @mysql_connect($dbhost, $dbuser, $dbpasswd);
@mysql_select_db($dbname,$db);
if ($db == \"\") {
die(\"Failed to connect to server! YOUR SCREWED!!\");
}
// Get data
if($type == \"posts\") {
$sql = \"SELECT * FROM phpbb_topics ORDER BY topic_time DESC LIMIT 5;\"; //note phpbb_topics in this case worked for me seeing as how thats where the correct tables were...you will have to find and change this as necessary for it to work for you.
} else {
$sql = \"SELECT * FROM phpbb_topics ORDER BY topic_time DESC LIMIT 5;\";
}
$r = mysql_query($sql, $db);
if ($r == FALSE) {
die(\"Unable to get data!\");
}
// Display data
$rows = mysql_num_rows($r);
for ($row_number = 0; $row_number <= $rows - 1; $row_number++) {
$topic_title = mysql_result($r, $row_number, \"topic_title\");
$topic_title = stripslashes($topic_title);
$k = substr($topic_title, 0, $length) . \"...\";
$topic_id = mysql_result($r, $row_number, \"topic_id\");
$forum_id = mysql_result($r, $row_number, \"forum_id\");
$recent .= \"<li><a title=\'\" . $topic_title . \"\' class=\'forum\' href=\'\" . $urlPath . \"/viewtopic.php?t=\" . $topic_id . \"&sid=\" . $forum_id . \"\'>$k</a></li>\";
}
return $recent;
}
//end testing