PDA

View Full Version : Calling recent posts to a webpage



travis
December 31st, 2006, 03:58 AM
I used to know how to do this, with php how can you display recent posts to your forum on your home page?

hl
December 31st, 2006, 08:47 AM
Depends on the forum software. If it's like most, it's in MySQL.

Just do a nice SELECT * FROM `tablecontainingpostsname` ORDER BY `fieldcontainingeithertimeorid` (ASC/DESC depending on the field you're ordering by, figure it out) LIMIT 5

5 can be changed of course.

λ
December 31st, 2006, 12:52 PM
Alternatively, if your forum provides an RSS feed, you could use a package like XML_Feed_Parser (http://pear.php.net/manual/en/package.xml.xml-feed-parser.php) to parse and display it on your homepage.

although presumably you'd want some sort of caching mechanism to prevent your RSS feed from being hit on every load of the page

travis
December 31st, 2006, 12:53 PM
Depends on the forum software. If it's like most, it's in MySQL.

Just do a nice SELECT * FROM `tablecontainingpostsname` ORDER BY `fieldcontainingeithertimeorid` (ASC/DESC depending on the field you're ordering by, figure it out) LIMIT 5

5 can be changed of course.

All right thanks a lot.
And no I don't have an RSS fead.