Buck
Storage? I am Storage!
I am sure this is not new for many of you, but having never done this, I was surprised at how easy it is to code an RSS Feed with PHP and MySQL. I searched the Internet for code suggestions, and some were terribly complicated. It took me some time, and the simplest code turned out to be the best. This is an RSS Feed for an Intranet site, where the users will use Outlook 2013 to receive the RSS Feed updates.
Code:
<?php
header("Content-Type: application/xml; charset=ISO-8859-1");
include("config.php");
?>
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>Site</title>
<link>http://www.site.com</link>
<description>Site RSS Feeds</description>
<copyright>2015 Site. All rights reserved.</copyright>
<?php
$query = "SELECT date, comment, link, catTitle FROM updates WHERE newest = 'Y' && pane2 = '1' ORDER BY id DESC";
$result = $mysqli->query($query) or die($mysqli->error.__LINE__);
while ($data = $result->fetch_array())
{
echo '<item><title>'.$data['catTitle'].' Update:</title><description>'.$data['comment'].'</description>';
echo '<link>'.$data['link'].'</link></item>';
}
echo '</channel></rss>';
?>