These forums are currently read-only due to receiving more spam than actual discussion. Sorry.

It is currently Sat Dec 02, 2017 4:12 pm Advanced search

RSS from MySQL

If you are stuck or have questions regarding HTML or other Web technologies, ask your questions here. No question too dumb!

RSS from MySQL

Postby freeTinker » Thu Jul 07, 2011 9:11 pm

Can anyone help me put this together?

I want to create a RSS Feed from MySQL with PHP and I am going mad here trying to get something to work, this is new to me so any help would be greatly appreciated. Here is code I have grabbed online and adapted in file name, [feed.php]

Code: Select all
<?

// create rss content


$hostname_solutions = "io.my_site_name.com";
$database_solutions = "my_database_name";
$username_solutions = "my_user_name";
$password_solutions = "my_pw";
$solutions = mysql_pconnect($hostname_solutions, $username_solutions, $password_solutions) or trigger_error(mysql_error(),E_USER_ERROR);

$result = mysql_query("SELECT *
FROM  `solutions`
WHERE 1
LIMIT 0 , 30");

$date = date("D, j M Y G:i:s O");

header('Content-type: text/xml');

echo ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
echo ("<rss version=\"2.0\">\n");
echo ("<channel>\n");
echo ("<lastBuildDate>$date</lastBuildDate>\n");
echo ("<pubDate>$date</pubDate>\n");
echo ("<title>My_Feed_Title</title>\n");
echo ("<description><![CDATA[My_Feed_Description]]></description>\n");
echo ("<link>http:_site_link</link>\n");
echo ("<language>en-us</language>\n");

$ch=100;
while ($data = mysql_fetch_array($result)) {
$headline       = $data["headline_field"];
$posturl         = $data["url_field"];
$content         = $data["content_field"];

echo ("<item>\n");
echo ("<title>$headline</title>\n");
echo ("<link>$posturl</link>\n");
echo ("<description><![CDATA[$content]]></description>\n");
echo ("<guid isPermaLink=\"true\">$posturl</guid>\n");
echo ("</item>\n");
}
echo ("</channel>\n");
echo ("</rss>\n");
?>


When I link to feed.php it shows up fine, but reports "No Articles" - can anyone help?
freeTinker
<h5>
 
Posts: 14
Joined: Sun Jan 23, 2011 11:34 am
Location: USA-MA

Re: RSS from MySQL

Postby freeTinker » Fri Jul 08, 2011 12:24 am

Ignore above post, went another route and have things all working nice now
freeTinker
<h5>
 
Posts: 14
Joined: Sun Jan 23, 2011 11:34 am
Location: USA-MA

Re: RSS from MySQL

Postby James360Smith » Mon Sep 03, 2012 11:31 am

RSS stands for Real Simple Syndication. If we have any type of news, any tutorials, informational articles that are updated regularly, an RSS feed is a must have.

Here, I am going to show you - how to create a dynamic RSS feed to updates it automatically when we have added something to our site.

Database Requirements
The RSS feed requires the below listed information for each post that will be updated:
- Title
- Content or article summary
- Web url address to the updated article
- The date it was updated

The <channel> element has three basic child elements:
- <title> - Describe the title of the channel (e.g. site home page)
- <link> - Describe the hyperlink to the channel
- <description> - Describes the channel (e.g. My apps);
At the end, the two last lines close the 'channel' & 'rss' elements.
James360Smith
<h5>
 
Posts: 12
Joined: Wed Jun 13, 2012 12:47 pm
Location: Miami, Florida


Return to Help & Advice

Who is online

Users browsing this forum: No registered users and 1 guest