View Full Version : Code to list newest posts of a forum

09-13-2005, 07:56 PM
I want a section on my index page to show the latest posts in a certain category of my PHPbb forum. I can't figure out what code I should be using.

09-13-2005, 07:59 PM
Basically it's so people can post in the forum and I don't personally have to update the mainpage with new messages constantly.

09-13-2005, 08:24 PM
Well I've never looked at the PHPbb forum, but this should get you started,

Function GetLastPost($PostId) {
global $SqlHost;
global $SqlUser;
global $SqlPass;
global $SqlDb;

$link = mysql_connect($SqlHost, $SqlUser, $SqlPass) or die('Login details incorrect');
$db_selected = mysql_select_db($SqlDb, $link) or die('Database name incorrect');

$result = mysql_query("SELECT * FROM SomeTable WHERE TableId=$PostId ORDER BY FeildName desc");
while ($row = mysql_fetch_assoc($result))
echo $row['SomeData'];


just open the data base for your forum, and try to match up the table and feild names.


09-14-2005, 12:16 AM
You should try phpbbfetchall. It has loads of functions you could add to your site.


09-14-2005, 12:31 AM
Thanks guys, when I get off work I'll play around with the code and take a look at that site!