PHPBB3 get latest topics

Get Help With Your Code. PHP/Perl/Python/RoR/SQL/etc.

PHPBB3 get latest topics

Postby Kudos on Wed Aug 06, 2008 12:32 pm

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>
Jonathan Cremin
Minthost Support
http://minthost.com/support
User avatar
Kudos
Site Admin
 
Posts: 20
Joined: Fri Jul 18, 2008 5:02 pm

Re: PHPBB3 get latest topics

Postby nivek on Tue Dec 02, 2008 4:28 pm

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.
nivek
 
Posts: 11
Joined: Sat Jul 19, 2008 12:15 pm


Return to Coding Help

Who is online

Users browsing this forum: No registered users and 1 guest

cron