Forum Moderators: open
I was given this code to allow a daily RSS feed to pull catechism questions from a database on my server. I took the following code and saved it as catechism.php. It kind of worked - my RSS reader finds it fine, but as I'm sure you can see, it appears unformatted when I browse to catechism.php.
What I'd like to have is a page that will display only the Title and Question and Answer (description field) appear on a page that I can use as in include in my site.
Does that make any sense? And please remember I'm an absolute novice with XML so don't use too many big words!
<?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">";
header('Content-Type: text/xml');
$link = mysql_connect('localhost', 'user', 'password');
mysql_select_db('database');
$day_of_year = date('md'); #May 19 = '0519'
$qid = mysql_query("select title from daily_catechism where day_of_year = $day_of_year");
$qid2 = mysql_query("select description from daily_catechism where day_of_year = $day_of_year");
$pub = date('r', mktime(0, 1, 0, date('m'), date('d'), date('Y')));
list($title) = mysql_fetch_row($qid);
list($description) = mysql_fetch_row($qid2);
?>
<rss version="2.0">
<channel>
<title>Catechism RSS</title>
<link>http://www.mysite.com/catechism.php</link>
<description>Daily Reformed Catechism</description>
<managingEditor>my@email.com</managingEditor>
<item>
<title><?php print htmlentities($title);?></title>
<description><?php print htmlentities($description);?></description>
<pubDate><?php print $pub;?></pubDate>
</item>
</channel>
</rss>
You have a couple of different options: apply a CSS file to the output, i.e. insert the line <?xml-stylesheet href="mystyle.css" type="text/css"?> before <rss version="2.0"> linked to your stylesheet, or create an alternative text/html output marked up using HTML tags instead of RSS tags.