MyBB Community Forums

Full Version: how to display last thread from specify sub forum to my website?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i using this code to my php file :


<?php
define("IN_MYBB", 1);
require_once("./global.php"); // Change this if needed
$tlimit = 6; // How many titles you want

$query = $db->query("SELECT * FROM ".TABLE_PREFIX."threads ORDER BY `tid` DESC LIMIT $tlimit");
while($fetch = $db->fetch_array($query)){
echo '<body bgcolor="#E7EAC8"><ul style="list-style-image: url(http://crwscdn.appspot.com/bulletorange.png);padding:0px 0px 0px 10px;margin:0px 0px 0px 0px">
<li style="list-style-image: url(http://crwscdn.appspot.com/bulletorange.png);margin: -2px 0px;"><a style="text-decoration:none;color:#000000;font-family:verdana;font-size:11px" href="./showthread.php?tid='.$fetch['tid'].'target="_parent">'.$fetch['subject'].'</a><br /></li></ul>' . "\n";
}
?>

credit from this thread : http://community.mybb.com/thread-6190-page-45.html


but that code just list latest thread for all entire forum, i just want to display latest thread from specify sub forum, just like fid=8 for example, how about the code?
Change above to this;
<?php
define("IN_MYBB", 1);
require_once("./global.php"); // Change this if needed
$tlimit = 6; // How many titles you want

$query = $db->query("SELECT * FROM ".TABLE_PREFIX."threads WHERE fid='X' ORDER BY `tid` DESC LIMIT $tlimit");
while($fetch = $db->fetch_array($query)){
echo '<body bgcolor="#E7EAC8"><ul style="list-style-image: url(http://crwscdn.appspot.com/bulletorange.png);padding:0px 0px 0px 10px;margin:0px 0px 0px 0px">
<li style="list-style-image: url(http://crwscdn.appspot.com/bulletorange.png);margin: -2px 0px;"><a style="text-decoration:none;color:#000000;font-family:verdana;font-size:11px" href="./showthread.php?tid='.$fetch['tid'].'target="_parent">'.$fetch['subject'].'</a><br /></li></ul>' . "\n";
}
?>

Replace X with your specific forum id.
wowww!!! great!! Fast response, just right to the point!
1 Rate to you Yaldaram Big Grin
subhanallah