Forumfeed

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
ampersand
Forum Commoner
Posts: 54
Joined: Thu Nov 28, 2002 2:00 am
Location: Norway

Forumfeed

Post by ampersand »

Hey! I wanna make a rss forumfeed that gives me the latest posts on klipfolio and other rss readers..

This is the php code that selects the recent posts from my invision board, but how am I going to put it into action ? I don't even know how to start combining xml and php..

Code: Select all

<?
$dbhost1 = "localhost"; 
$dbuser1 ="UseRnaMe"; 
$dbpass1 = "pAsSwOrD"; 
$database1 = "database"; 
$ibf_prefix1 = "ibf_";

$db1 = mysql_connect($dbhost1, $dbuser1, $dbpass1) or die ("Could not connect to database");
mysql_select_db ($database1, $db1) or die("Unable to select database!");


function iif($expression, $returntrue, $returnfalse="")
{

	if ($expression) 
	{
		return $returntrue;
	} 
	elseif (!$expression) 
	{
		return $returnfalse;
	}

}


$recentforumget = "10"; // Number of posts to get
$forumexclude = "24,25,26,31"; // Add forum id's to exclude from get (eg private ones) separate by a 
$forumpath = "http://www.mydomain.com/forum";



$getposts = mysql_query("SELECT tid, title, forum_id, starter_id, starter_name, last_poster_id, last_poster_name, last_post FROM ".$ibf_prefix1."topics WHERE (state = 'open')".iif($forumexclude," AND (forum_id NOT IN ($forumexclude))")." ORDER BY last_post DESC LIMIT $recentforumget") or die (mysql_errno().": ".mysql_error()."<br />");

echo "<table width="100%">";  

while ($post = mysql_fetch_array($getposts)) 
{
	$post[last_post] = date("m-d-Y @ h:i A",$post[last_post]-$timeoffset);

	echo "<tr>";

	
	echo "<td valign="top"><img src="$mosConfig_live_site/images/M_images/arrow.png" alt="" /></td>";
	echo "<td>";
	echo "<a href="".$forumpath."/index.php?act=ST&f=";
	echo "".$post['forum_id']."&t=";
	echo "".$post['tid']."&view=getlastpost">";
	echo "".$post['title']."</a></td>";
	echo "</td>";
	echo "</tr>";
} 
echo "</table>";

?>
Thanks in advance
Post Reply