Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Solved: 2 Years, 2 Months, 2 Weeks ago [How To?] Display threads from a specific forum on my main websites index.php
#6
Solved: 2 Years, 2 Months, 2 Weeks ago
Alright, for those of you that were wondering I was able to get this working exactly how I wanted it. It displays the subject of the post as well as the post content.

Here is the code... Thanks to everyone that helped me!

<?php
chdir("./forum/"); // path to MyBB
define("IN_MYBB", 1);
require("./global.php");
global $mybb, $db, $cache, $lang, $plugins;  // Trim this list of global vars, if you want to.
?>

<?php
$query = $db->query("
    SELECT t.tid, t.fid, t.uid, t.username, t.subject, t.replies, t.views, t.lastposter, p.message
    FROM ".mybb_."threads t
    INNER JOIN ".mybb_."posts p ON (p.tid=t.tid)
    WHERE t.fid='3' AND t.visible='1'
    ORDER BY t.dateline DESC
    LIMIT 6
	"// Change the last digit to how many recent post you want to be shown
	
); 
$list = '';
    while($fetch = $db->fetch_array($query))
    {
        $list .= "<strong><a href=\"forum/showthread.php?tid={$fetch['tid']}\">".htmlspecialchars_uni($fetch['subject'])."</a></strong><br />";
		$list .= "".htmlspecialchars_uni($fetch['message'])."<br>";
        $poster = "<a href=\"forum/member.php?action=profile&uid=".$fetch['uid']."\">{$fetch['username']}</a>";
        $list .= "Posted by: {$poster}<br /><br />";
    
    }
    //output
    echo $list;
?>
Reply


Messages In This Thread
RE: Display threads from a specific forum on my main websites index.php - by DemonReborn - 06-02-2017, 09:41 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)