I'm sorry if someone had already posted about it, but I have made some searches
and did not find anything simmilar.
RSS, very used nowadays by most of sites and it is one of the innovations that
came with the famous Web2.0
For who doesn't know, RSS is a subset of dialects XML that are use to join content or
Web syndication could be acceded by programmes/websites packers.
It is used mainly in sites of news and blogs.
The abbreviation of RSS is used to refer to the following patterns:
- Rich Site Summary (RSS 0.91)
- RDF Site Summary (RSS 0.9 e 1.0)
- Really Simple Syndication (RSS 2.0)
The technology of RSS allows to the users of the internet to enroll in sites that supply
feeds RSS. Those are typically sites that changes or update their content regularly.
For that, they are used Feeds RSS that receive these updatings, of this it sorts out the user
can stay informed of several updatings in several sites without needing to visit them one to one.
The feeds RSS offer content Web or content summaries together with the links for
the complete versions of this content and other data.
This information is given as a file XML called RSS feed, webfeed, Atom or still channel RSS.
An example of as it should follow our RSS
CODE
<?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0">
<channel>
<title>Asta Feeds</title>
<description>Astahost Forum Feeds</description>
<link>http://www.astahost.com/index.php</link>
<language>eng-uk</language>
<item>
<title>Columm Title</title>
<description>Columm Description</description>
<lastBuildDate>Feeds Date</lastBuildDate>
<link>http://www.astahost.com/index.php?action=feeds&id=1>/link>
</item>
</channel>
</rss>
<rss version="2.0">
<channel>
<title>Asta Feeds</title>
<description>Astahost Forum Feeds</description>
<link>http://www.astahost.com/index.php</link>
<language>eng-uk</language>
<item>
<title>Columm Title</title>
<description>Columm Description</description>
<lastBuildDate>Feeds Date</lastBuildDate>
<link>http://www.astahost.com/index.php?action=feeds&id=1>/link>
</item>
</channel>
</rss>
Tags above, are pattern Tags that it should be maintained.
Only what will vary inside of the tags above it is TAG <item></item>.
we will create the item tag in the amount of columns or registrations that we will look for in the database.
Now the code php that makes the magic:
Feed RSS:
CODE
<?
$rss = '<?xml version="1.0" encoding="iso-8859-1"?>';
$rss .= '<rss version="2.0">';
$rss .= '<channel>';
$rss .= '<title>Asta Feeds</title>';
$rss .= '<description>AstaHost Forum Feeds</description>';
$rss .= '<link>http://www.astahost.com/index.php</link>';
$rss .= '<language>eng-uk</language>';
$rss = '<?xml version="1.0" encoding="iso-8859-1"?>';
$rss .= '<rss version="2.0">';
$rss .= '<channel>';
$rss .= '<title>Asta Feeds</title>';
$rss .= '<description>AstaHost Forum Feeds</description>';
$rss .= '<link>http://www.astahost.com/index.php</link>';
$rss .= '<language>eng-uk</language>';
Database Conection:
CODE
$connect = mysql_connect('localhost','username','password');
Selecting Database:
CODE
mysql_select_db('base',$connect);
$rs_rss = mysql_query("SELECT id, title,description,date FROM table_colums ORDER BY date DESC LIMIT 20", $connect);
$rs_rss = mysql_query("SELECT id, title,description,date FROM table_colums ORDER BY date DESC LIMIT 20", $connect);
Creating a varible $content NuLL
CODE
$content = "";
Adding contents to the variable($contents):
CODE
while($creating=mysql_fetch_object($rs_rss))
{
$content .= '<item>';
$content .= "<title>$creating->title</title>";
$content .= "<description>$creating->description</description>";
$content .= "<lastBuildDate>$creating->date</lastBuildDate>";
$content .= "<link>http://www.astahost.com/index.php?action=feeds&id=".$creating->id."</link>";
$content .= '</item>';
}
[code]
[i]Together $rss plus $content to $xml:[/i]
[code]$xml = $rss.$content;
{
$content .= '<item>';
$content .= "<title>$creating->title</title>";
$content .= "<description>$creating->description</description>";
$content .= "<lastBuildDate>$creating->date</lastBuildDate>";
$content .= "<link>http://www.astahost.com/index.php?action=feeds&id=".$creating->id."</link>";
$content .= '</item>';
}
[code]
[i]Together $rss plus $content to $xml:[/i]
[code]$xml = $rss.$content;
Closing the tags
CODE
$xml .= '</channel></rss>';
After we create our rss, we will record it in disk for us to use.
This opens the file for reading and writing; it puts the pointer of the file in the beginning
and it decreases (it truncates) the size of the file for zero.
If the file doesn't exist, try to create it (w+).
CODE
$feedsfile = fopen('folder/articles.xml','w+');
Recording into artivles.xml
CODE
fwrite($feedsfile,$xml);
Closing file
CODE
fclose($feedsfile);
?>
?>
This code searchs on database, returns the last twenty registers and save into .xml document.
Yours, Impious

