Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Display a list of recent topics

Hey Kevin,

I tried your code, it’s not working.

@ everyone:

I added this piece of code (".$result->topic_posts.") to show the number of replies on each topic, so now the code is like this:

<div id="recentetopics">
<h2>Recente topics</h2>
<ul>
<?php
global $bbdb;
$query="SELECT * FROM bb_topics WHERE topic_status=0 ORDER BY topic_start_time DESC LIMIT 10";
$results=$bbdb->get_results($query);
foreach ($results as $result) {
echo "<li>".date( strtotime( $result->topic_start_time ) < floor( current_time( 'timestamp' ) / 86400 ) * 86400 ? 'd M' : 'H.i', bb_offset_time( strtotime( $result->topic_start_time ) ) )." &rarr; <a href='/topic.php?id=".$result->topic_id."'>".$result->topic_title."</a> (".$result->topic_posts.")</li>";
}
?>
</ul>
</div>

The output is like this:

19.11 → Dark Mirror Ov Tragedy - The Pregnant Of Despair (2009) (4)
19.00 → Rammstein - Live In Muenchen (2009) (2)
18.54 → Mnemic - Sons Of The System (2010) (1)
26 Jan → Aanraders? (2)
25 Jan → Duitse band Scorpions stopt (2)

I notice that topics that don’t have any replies yet, it shows the number 1 as the number of replies. It should show zero actually.

Whadya you guys think?

Skip to toolbar