About Me

My Photo
k. novianto
Hello just call me Novi. Not like script and programing code, my life is simple. Thank you for visiting my blog. Enjoy
View my complete profile

How to Create RSS Feed on your Website

Very simple to create RSS feed. You just add header of XML file on your page header, and select from table and loop your data into xml format.

<?php
require_once(”dbconnection.php”);
$query = “select address, cat, desc, title from `category` limit 15?;
$result = mysql_query($query, $link);

while ($line = mysql_fetch_assoc($result))
{
$return[] = $line;
}

$now = date(”D, d M Y H:i:s T”);

$output = “<?xml version=\”1.0\”?>
<rss version=\”2.0\”
xmlns:content=\”http://purl.org/rss/1.0/modules/content/\”
xmlns:wfw=\”http://wellformedweb.org/CommentAPI/\”
xmlnsdc=\”http://purl.org/dc/elements/1.1/\”
>
<channel>
<title>Judul RSS FEED</title>
<link>http://domain.com/feed.php</link>
<description>Deskripsi RSS</description>
<language>en-us</language>
<pubDate>$now</pubDate>
<lastBuildDate>$now</lastBuildDate>
<docs>http://domain.com</docs>
<managingEditor>mail@mail.co.id</managingEditor>
<webMaster>mail@mail.com</webMaster>
“;

foreach ($return as $line)
{
$output .= “<item><title>”.htmlentities($line[’title’]).”</title>
<link>”.htmlentities($line[’address’]).”</link>

<description>”.htmlentities(strip_tags($line[’desc’])).”</description>
</item>”;
}
$output .= “</channel></rss>”;
header(”Content-Type: application/rss+xml”);
echo $output;
?>


This blog is wearing Sederhana, a free XML Blogger Template adopted from Oh My Grid - WP theme by Thomas Arie
copyright 2008 - SOLO webdesign
email: soloweb.dev@gmail.com
phone: +6201329494035