PDA

View Full Version : Latest Posts Script showing moderated posts


chrisbr
12-21-2013, 05:35 PM
Hi There

I have a version of a latest post script which displays the latest posts onto a non VB page, however, I've noticed that it is displaying posts which are automatically moderated by the forum software.

Is there any way I can stop moderated posts from being shown on my latest posts script?

<?php
include("global.php");
//Config ID here
$exclude = array('15','22');


$exclude_list = "";
foreach($exclude as $key => $value)
{
$list_forum = $db->query_read("
SELECT *
FROM " . TABLE_PREFIX . "forum
WHERE `parentlist` LIKE '%$value,%'
");
while ($forum = $db->fetch_array($list_forum))
{
$exclude_list .= $forum['forumid'] . ",";
}
}
$exclude_list .= "0";

function cutnchar($str,$n)
{
if(strlen($str)<$n) return $str;
$html = substr($str,0,$n);
$html = substr($html,0,strrpos($html,' '));
return $html . '...';
}
$lasttopics = $db->query_read("
SELECT *
FROM " . TABLE_PREFIX . "thread
WHERE forumid NOT IN (" . $exclude_list . ")
ORDER BY threadid DESC
LIMIT 5
");//LIMIT 5 Is number post will be show
while ($topic = $db->fetch_array($lasttopics))
{
?>
<li><span><?php echo date("d.m.y",$topic['dateline']); ?></span><a href="http://mydomainname.com/boards/showthread.php?<?php echo $topic['threadid']; ?>"><?php echo cutnchar($topic['title'],25); ?></a></li>
<?php
}
?>

kh99
12-21-2013, 05:50 PM
I think you just need to check the visible field of the thread table, like (add the middle line):

WHERE forumid NOT IN (" . $exclude_list . ")
AND visible = 1
ORDER BY threadid DESC

chrisbr
12-21-2013, 06:00 PM
Super! That's done the trick

Thanks for the help and the prompt reply :)