Jump to content
xisto Community
Sign in to follow this  
owbussey

How Do You Use Php To Make A Rss Feed? Is It Possible?

Recommended Posts

I use a lot of php and am trying to make an RSS feed using it. I have not been very succesful. Do I need to use XML or a content manager? I am just starting, but I think I know my stuff. Any suggestions would be appreciated. I would greatly like to keeep people up tp date about my website.

Share this post


Link to post
Share on other sites

Making an RSS feed using PHP is not really that hard, but you need to understand how RSS feed files are compiled. If you look at an RSS feed file, it has the extension XML, and the information in the file is simply XML data that you put there. I created the feed here for a friend's site using PHP. When they write a new article for the site, or edit an existing one, the RSS file also gets updated. Then anyone with it in their RSS reader will get the new file when they check.

Here's the file I wrote to update the RSS file. It's not particularly well coded or commented, but you should be able to understand it. If not, feel free to email or PM me.

<?php//Include the database connection fileinclude('dbconn.php.inc');$query = "SELECT * FROM fc_content ORDER BY timestamp DESC LIMIT 5";$result = mysql_query($query);$file = fopen("rss.xml", "w");fwrite($file, '<?xml version="1.0"?><rss version="2.0"><channel><title>Ferret Crossing RSS Feed</title><link>http://forums.xisto.com/no_longer_exists/ the latest information from Ferret Crossing delivered direct to your RSS reader.</description><language>en-gb</language>');while($row = mysql_fetch_assoc($result)){	if($row['short'] == ""){		$description = $row['content'];	}	if($row['short'] != ""){		$description = $row['short'];	}	$description = strip_tags($description);	$description = substr($description, 0, 100);	fwrite($file, '<item>\n<title>'.$row["title"].'</title>\n<link>http://forums.xisto.com/no_longer_exists/, '</channel></rss>');fclose($file);?>

Share this post


Link to post
Share on other sites

To build a rss feed in php scratch try out some tutorial sites like pixel2life. Also if you use cute news they do rss feeds automatically as well.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.