Page 1 of 1

PHPBB3 get latest topics

PostPosted: Wed Aug 06, 2008 12:32 pm
by Kudos
While looking for some code to insert the latest topics on the homepage, I discovered a load of poor implementations. Here's mine:

Code: Select all
<h3>from the forum</h3>
<ul>
<?php
$connection = mysql_connect(localhost,'username','password') or die("Service temporarily unavailable"); //use @ before the function to supress errors and remove the die after it for production use
$db = mysql_select_db('databasename',$connection) or die("Service temporairly unavailable");//do the same here
$sql = "select * from phpbb_topics order by topic_last_post_time desc limit 0,4";// i use " where forum_id != 3" as the where clause to exclude topics from the announcements forum
$result = mysql_query($sql);// @ again for production
while ($row = mysql_fetch_array($result))
{
   echo '<li><h4><a href="http://forum.minthost.com/viewtopic.php?f='.$row[forum_id].'&t='.$row[topic_id].'">'.$row[topic_title].'</a></h4><p><a href="http://forum.minthost.com/viewtopic.php?f='.$row[forum_id].'&t='.$row[topic_id].'">read more</a></p></li>';
}
?>
</ul>

Re: PHPBB3 get latest topics

PostPosted: Tue Dec 02, 2008 4:28 pm
by nivek
Nice. I was actually browsing for an implementation a while back. Completely forgot I had seen this here. Although since I switched to Invision Power Board (IPB) I haven't yet tried to implement anything. I must have a look into coding up something.