$link = ($component == 1) ? '' : '2';
$query="SELECT topic_title, topic_id, t.topic_time, t.topic_poster, t.topic_last_post_id AS topic_poster_id, u.username AS topic_poster
FROM " .$phpbb_prefix . "topics t
LEFT JOIN " .$phpbb_prefix . "forums f ON f.forum_id = t.forum_id
LEFT JOIN " .$phpbb_prefix . "users u ON t.topic_poster = u.user_id
WHERE f.auth_read <= $forum_access AND t.topic_views != 0
ORDER BY t.topic_last_post_id DESC LIMIT 0, $number";
$db->setQuery($query);
echo $db->getErrorMsg();
$rows = $db->loadObjectList();
//check if there is result
if(count($rows) > 0){
for($i=0,$n=count($rows);$i<$n;$i++){
$row = &$rows[$i];
$topic_title = $row->topic_title;
if(strlen($topic_title) > $titlelenght){
$topic_title = substr($topic_title, 0, ($titlelenght - 2)) . "...";
}
$topic_id = $row->topic_id;
echo '+ ';
echo ''.$topic_title."";
if($display_time == 1){
if(!empty($title_time_separator)){
echo " " . $title_time_separator;
}
echo " " . strftime($time_format, $row->topic_time);
}
if($display_user == 1){
if(!empty($time_user_separator)){
echo " " . $time_user_separator;
}
echo ' '.$row->poster."";
}
echo "\n";
}
}
else {
echo '+ No topics found';
}
?>
|