Created
November 23, 2013 07:26
-
-
Save itsbalamurali/7611857 to your computer and use it in GitHub Desktop.
RSS Generator =========== You'll need a MySQL database with a a table called `rss_feed`. In that table there are 3 colums: item title (which is the name a person will see for an item), the item link (which is the location of the page with the item on it), and description (which tells what the feed is about). Put the file in a folder called feed …
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Connect to database... (you'll need to create this yourself) | |
| require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/connection.php'; | |
| // Run query... | |
| $getFeed = mysql_query("SELECT * | |
| FROM `rss_feed` | |
| ORDER BY `time` DESC | |
| ")or die(mysql_error()); | |
| // Output XML (RSS) | |
| echo '<?xml version="1.0" encoding="ISO-8859-1" ?> | |
| <rss version="2.0"> | |
| <channel> | |
| <title>Your RSS Title</title> | |
| <link>http://the_location_of_your_feed/feed</link> | |
| <description>Description of your Feed</description> | |
| <language>English</language> | |
| <image> | |
| <title>website Logo</title> | |
| <url></url> | |
| <link>Link to image</link> | |
| <width>width</width> | |
| <height>height</height> | |
| </image>'; | |
| while($rssFeed = mysql_fetch_array($getFeed)) { | |
| echo '<item>', | |
| '<title>', $rssFeed['item_title']</title>', | |
| '<link>', $rssFeed['link'], '</link>', | |
| '<description><![CDATA[ ,$rssFeed['description'],']]></description> | |
| </item>'; | |
| } | |
| echo '</channel> | |
| </rss>'; | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment