Jul 24, 2008

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

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > PHP Programming

free web hosting

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

owbussey
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.

Reply

Arne-Christian
Read:

http://www.sigsource.com/tutorials.php?&am...=full&id=50

Reply

rvalkass
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.
CODE

<?php
//Include the database connection file
include('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://www.ferret-crossing.co.uk/</link>
<description>All 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://www.ferret-crossing.co.uk/</link>\n<description>'.$description.'...</description>\n</item>');
}

fwrite($file, '</channel></rss>');
fclose($file);
?>

 

 

 


Reply

Saint_Michael
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.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics

Keywords : php rss


    Looking for php, make, rss, feed

Searching Video's for php, make, rss, feed
advertisement



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



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE