getButterfly Logo getButterfly code wrangling since 2005

I’m talking here about extracting latest posts to a different site. I’m also assuming that the databases are on the same server.

So here is the script:

// connect to the database server

// run The query
$results = mysql_query(“SELECT * FROM phpbb_topics ORDER BY topic_time DESC LIMIT 10”);
if ($results) {
while($rand = mysql_fetch_array($results)) {
echo “<div>”;
echo “<a href=’”.$rand[0].”‘ target=’_blank’ title=’Open in new window’>”;
echo $rand[6];
echo “</a><br /><small>&raquo; added by “.$rand[16].”</small>”;
echo “</div>”;
else {
echo “<p>Error: Forum not available.</p>”;


The last line of the script reopens the previous connection, if any. If you don’t use any MySQL databases on your main site, then remove the last database selection line. You should take care and replace phpbb_ with your database prefix (usually phpbb_). You should also change the number of posts you want to extract (10 in my example). Feel free to open the phpbb_topics table and extract new info. I’m using $rand[x] to extract my info, where x is the column number in the phpbb_topics table (starting from 0).

Subscribe to getButterfly Blog

Once a week or so we send an email with our best content. We never bug you, we just send you our latest piece of content.

If you found any value in this post, agree, disagree, or have anything to add - please do. I use comments as my #1 signal for what to write about. Read our comment policy before commenting! Comments such as "Thank you!", "Awesome!", "You're the man!" are either marked as spam or stripped from URL.

One thought on “How To Extract Latest Posts From phpBB Forums

  1. is there any way that we can extract one whole section in text format along with php codes? for example there is a ebooks section with 100 posts. if these 100 posts can be extracted in txt file keeping their codes incontact if any…[img], [code][/code] along with other text if available so that that ready made thing can be posted to some other forum or site

Leave a reply