<? 
header('Content-type: text/xml'); 
?>

<rss version="2.0">
<channel>
<title>Birmingham Aero Club News</title>
<description>Aviation News for Members of the Birmingham Aero Club</description>
<link>http://www.birminghamaeroclub.org/</link>
<copyright>Copyright The Birmingham Aero Club</copyright>

<?php

/*

from http://www.tiffanybbrown.com/2005/12/22/dynamic-rss-feeds-using-php-mysql-and-apache

RSS files, like all XML files, are static text. To make our feed dynamic, were going to tell our server to treat files with an .xml extension as PHP files.
To do that, simply create a file named .htaccess. Add AddType application/x-httpd-php .xml and save it to your server. If you have access to your servers configuration (httpd.conf) file, you can put the AddType declaration there instead.
Keep in mind that this will cause all files with an .xml extension in that directory (or on your server) to be parsed as PHP.

*/

//include ("inc/dbopen.php");

include("include/database.php");
//Get all the articles for the last month
//$result = mysql_query("select id, DATE_FORMAT(article_date,'%m/%d/%Y')article_date, title, brief, article_text from articles where article_date > DATE_SUB(curdate(), INTERVAL 1 MONTH)and page_type = 'a' order by article_date desc");	

    $result = $database->query("select id, DATE_FORMAT(article_date,'%m/%d/%Y')article_date, title, brief, article_text from articles where article_date > DATE_SUB(curdate(), INTERVAL 1 MONTH)and page_type = 'a' order by article_date desc");		

if ($result) 
	{
	if (@mysql_num_rows($result))
		{		
		while ($row = mysql_fetch_array($result)) 
	     	{
 	
			/* original example
			<item>
			<title> <?=htmlentities(strip_tags($result['title'])); ?></title>
            <description> <?=htmlentities(strip_tags($result['body'],'ENT_QUOTES'));?></description>
            <link>http://yoururl.com/pathtostory/and_page.php?p=<?=$result['id'];?></link>
            <pubDate> <?=strftime( "%a, %d %b %Y %T %Z" , $result['pubDate']); ?></pubDate>
            </item>
			*/
			
			echo ('<item>');
			echo ('<title>' . $row[title] . '</title>');
			echo ('<description>' . $row[brief] . '</description>');
			echo ('<link>' . 'http://www.birminghamaeroclub.org/article.php?id=' . $row[id]. '</link>');
			echo ('<pubdate>' . $row[article_date] . '</pubdate>');
            echo ('</item>');
						
    		} 	
		} 
	else
		{ 
		//echo('<p><b>Error: Query did not return any rows.</p>'); 
		}
	}
else 
	{ 
	echo('<p><b>Error: Query Failed</b> '.mysql_error().'</p>'); 
	}
   		
/***mysql_close();  ***/
?>

</channel>
</rss>

