Forgot Password / Register
Site Statistics
Total Members: 509
Total Tutorials: 242
Newsest User: Lestop
Todays Unique Hits: 204
0 Users 2 Guests Online

RSS Feed

This will be a continuation of: http://rmb-scripting.com/tutorials.php?tutorial&tid=21

Now first off, create a new file and anme it rss.php or what ever you want.

When you are finished open it up and type up something like the following:
PHP Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
header
('Content-type: text/xml'); //change file type to XML
include("db.php");  //get config
?>
<rss version="2.0">
<channel>
    <title>Feed Name</title>
    <description>Feed Descriptiondescription>
    <link>http://yoursite.com</link>
<?
$result 
mysql_query("SELECT * FROM entries ORDER BY id DESC"); //get the information
while($row mysql_fetch_assoc($result)){ //repeat the info
?>
<item>
     <title><?=$row['title']; //echo the title
?></title>
     <description><?=$row[short]; //echo the content
?></description>
     <author>SiteName submissions@yoursite.com</author>
     <link>http://yoursite.com/index.php?id=<?=$row['id']; //another link to the article
?></link>
     <guid>http://yoursite.com/#<?=$row[id];// Quick Link
?></guid>
</item>
<?
//end the while
?>
</channel>
</rss>


Be sure to change all your variables and upon checking it with W3C Feed Validator it is valid.

For a live example you can see mine at:
http://hrwp.exofire.net/hrwp_new/rss.php

Now you have to edit your .htaccess file =P

Please add the code below so that instead of rss.php you could use news.xml or something else.

Code

RewriteEngine On
RewriteRule ^(.*).xml$ rss.php


You can have anything with the extension of .xml which will link up to your news rss file!
ShadowMage
Author:
Views:
2005
Rating:
Posted on Thursday 18th October 2007 at 09:55 PM
Arudis
Arudis
omg iv been looking all over the internet for a guide like this thanks