Return to “Technical”

Post

Easy Forum grab for off line or reformatting

#1
When I used to run a phpbb site I found it hard to read all the posts, so I created a way to easily grab all the posts in a forum and dump them to my phone to read. The following php script could be parametised of course so the forum id is not hard coded. This simple script grabs all the posts from a specified forum with the user name who did each post and displays it on the web page so a person can copy and paste it all to another device or any document.

The following is useful also for ideas forums if you want to grab the forum and reformat the ideas into a document.



<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Forum Grab</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
</head>


<body bgcolor="#D89024">

<?php
$dbuser="yourDBusername";
$dbpass="yourDBuserpass";

$fid="5"; // <---- forum Id you can change that to the forum id you want to dump

$dbname="yourDBName";
$chandle = mysql_connect("localhost", $dbuser, $dbpass)
or die("Connection Failure to Database");
mysql_select_db($dbname, $chandle) or die ($dbname . " Database not found. " . $dbuser);


$query1="select * from phpbb_posts as t1 LEFT JOIN phpbb_users as t2 ON t1.poster_id=t2.user_id where t1.forum_id = '" . $fid . "' order by t1.topic_id ASC, t1.post_id ASC";
$result = mysql_db_query($dbname, $query1) or die("Failed Query of " . $query1);

while($row = mysql_fetch_array($result))
{
echo "<br />";
echo "<br />";
echo '<a><b>' . $row['username'] . '</b></a>';
echo "<br />";
echo '<a><b>' . $row['post_text'] . '</b></a>';
}
echo "<br />";

?>


</body>
</html>
Last edited by Jason S on Tue Nov 27, 2012 2:07 am, edited 3 times in total.

Online Now

Users browsing this forum: No registered users and 8 guests

cron