MyBB Community Forums

Full Version: Show latest posts on website?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, is there a way I can show the latest forum posts on my main website?
See http://community.mybboard.net/showthread.php?tid=13430

There's a section in the first post that shows you how to put the recent posts on your homepage.
DennisTT Wrote:See http://community.mybboard.net/showthread.php?tid=13430

There's a section in the first post that shows you how to put the recent posts on your homepage.

I'm having issues with it.

http://appleaday.cn/index.php

I put the script in the right column, all it says it "by"

What's wrong??
Maybe this helps ::

<?php

// Root Of Forum
$root = "mybb129";
// Posts To Show
$max = 5;
// Table Prefix
$prefix = "mybb_";
// Forum ID
$fid = 2;

define('IN_MYBB', 1);
chdir($root);
require "./global.php";

// Get Posts
$query = $db->query("SELECT * FROM ".$prefix."posts WHERE fid=$fid ORDER BY dateline DESC LIMIT 0,$max");
while($posts = $db->fetch_array($query))
{
//PostInfo
$tid = $posts['tid'];
$pid = $posts['pid'];
$subject = $posts['subject'];
$subject = str_replace("RE:","",$subject);
$date = date("H:i / d-m", $posts['dateline']);
$message = $posts['message'];
if(my_strlen($message) > 50)
{
	$message = substr($message, 0, 40)."...";
}
//UserInfo
$username = $posts['username'];
$uid = $posts['uid'];
require_once "inc/functions_user.php";
$link = build_profile_link($username, $uid);
//Posts
$post .= ":: <strong>Thread: </strong> <a href=\"{$root}showthread.php?tid={$tid}&pid={$pid}#pid={$pid}\">{$subject}</a> By ".$link." On ".$date." :: <br /><br /><strong>Message: </strong>{$message}<br /><br />";

}

echo $post;

?>
Thanks lex Smile
Would it be easier to create some form of javascript code from the RSS? There is a great mod for phpbb that does that and it works well as the code can be placed ANYWHERE without the need to edit php or access the database. Safer imho.