MyBB Community Forums

Full Version: Got a code but need some modification....
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I'm trying to get a script which pulls all the threads from a specific forum ID and prints the Thread titles, the first message of the thread, date, author, link to the thread (and number of replies to the thread). I'm planning on using it as a news script which I eventually want to implement into my html website. Since the Site News plugin doesn't seem to work for me I'm trying to do it a different way.

DCR posted this code in a different thread here over at MyBB:

<?php

//What is the name of the directory of your forums?
$forums = ""; //ex: forum.

//How many posts do you want to show?
$posts = 5;

//No more editing needed.

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

$query = $db->query("SELECT * FROM ".TABLE_PREFIX."posts ORDER BY dateline DESC LIMIT 0,$posts");
while($b = $db->fetch_array($query))
{

    $tid = $b['tid'];
    $pid = $b['pid'];
    $subject = $b['subject'];
    $date = date("g:iA (M-j)", $b['dateline']);
    

    $username = $b['username'];
    $uid = $b['uid'];

    require_once "inc/functions.php";
    $link = build_profile_link($username, $uid);
    //Posts
    $post = '<a href="showthread.php?tid='.$tid.'&pid='.$pid.'#pid='.$pid.'">'.$subject.'</a> By '.$link.' at '.$date.'<br /><br />';
    echo $post;
}
chdir("./");
?>

Which essentially gets the x number of latest post from your forum. So this pretty much covers the basic. Now I need to figure out how to posts the first message of all the threads from a certain forum ID.

Is there anybody willing to help me out, point me in the right direction or can help me in any other way? I have no coding knowledge and most of the time I try things until it works.
There's a tutorial in the User Tutorials section labeled "Displaying News on your homepage".

Linkydoo:
http://community.mybboard.net/showthread.php?tid=22068
ahero4heor Wrote:There's a tutorial in the User Tutorials section labeled "Displaying News on your homepage".

Linkydoo:
http://community.mybboard.net/showthread.php?tid=22068
Oooops sorry, Thank You!
It's alright, a lot is easy to miss. I missed it the first time I looked through there, when looking for the link for ya.