Dynamic RSS Feed Help XML/PHP
Posted: Wed Sep 09, 2009 2:26 am
I programmed a Dynamic RSS Feed Script and saved it as rss.php
But when i open it on browser, Here is what I see:

I want to display it on rss style, How do i do that?
Here is the source
But when i open it on browser, Here is what I see:

I want to display it on rss style, How do i do that?
Here is the source
Code: Select all
<?php
header('Content-Type: text/xml');
echo '<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="2.0">
<channel>
<title>My Website Name</title>
<description>A description of the feed</description>
<link>The URL to the website</link>';
$db_host = 'localhost'; // host name
$db_user = 'root'; // db username
$db_pass = ''; // db user passwod
$db_name = ''; // database
$connection = mysql_connect($db_host, $db_user, $db_pass)or die(mysql_error());
$sel = mysql_select_db($db_name)or die('cant connect to the database');
$get_articles = "SELECT `index` , `news` , `title`, DATE_FORMAT(date,'%a, %e %b') as formatted_date FROM `content` ORDER BY `index` DESC LIMIT 10";
$articles = mysql_query($get_articles) or die(mysql_error());
while ($article = mysql_fetch_array($articles)){
echo '
<item>
<title>'.$article[title].'</title>
<description>', htmlentities(strip_tags(substr(
$article['news'], 0, 100))), '</description>
<link>http://localhost/tec/blog.php?id='.$article[index].'</link>
<pubDate>'.$article[formatted_date].'</pubDate>
</item>';
}
echo '</channel>
</rss>';
?>