Jump to content

PHP into xml/rss


levidyllan

Recommended Posts

To explain what I am after heres what I want to do, a bit of background.

 

I have a flash file that I am currently programming (AS2) which will have a section that will have dynamically loaded text.

 

Now this text will be within a MySQl db.

 

Now I used to have a a php file that I used for my RSS page and what this did would when called (myRss.php) would connect to the db then fetch the details I want then convert it to rss/xml and display as a RSS page.

Due to stupid old me I seemed to have deleted my only copy of the php code and this would have been ideal to use for my flash inwhich to call then get the data

 

Another way which I have not dabbeled is using php within flash direct, which could be another possibility.

 

Any way if any body knows of any good eg's of such code this would be great

 

many thanks me

Link to comment
Share on other sites

I have found and used this:

<?php
header('Content-type: text/xml');
echo '<?xml version="1.0" encoding="UTF-8"?>';
// Set RSS version.
echo '
<rss version="2.0"> ';
// Start the XML.
echo '
<channel>
<title>???</title>
<description>???</description>
<link>???>/link>';
// Create a connection to your database.
  require_once ('connection file'); // Connect to the db.
// Query database and select the last 10 entries.
$data = mysql_query('SELECT * FROM ??? ORDER BY ??? DESC');

while($row = mysql_fetch_array($data))
{
echo '
<item>
<title>'.$row['headn'].'</title>
<pubdate>'.$row['date'].'</pubdate>
<description><![CDATA['.$row['news'].']]></description>
<link>'.$row['link'].'</link>
</item>';
}
echo '
</channel>
</rss>';

?>

 

cheers

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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.