sam20
asked on
Retrieve data from MySQLl database in xml file
I have a rss xml file which works fine please see below code. I will replace title, link, description and date with data from MySQL database.
<?xml version="1.0"?>
<rss version="2.0" xmlns:atom="http://-.info/rss/Atom">
<channel>
<title>TITLE</title>
<link>http://-.info/</link>
<description>Whatever Company News</description>
<language>en-us</language>
<pubDate>Mon, 4 Feb 2008 04:00:00 GMT</pubDate>
<lastBuildDate>Mon, 4 Feb 2008 04:00:00 GMT</lastBuildDate>
<docs>http://127.0.0.1/rss</docs>
<generator>Weblog Editor 2.0</generator>
<item>
<title>News Article #1</title>
<link>http://www.--.htm</link>
<description>Whatever new article</description>
<pubDate>Mon, 4 Feb 2008 04:00:00 GMT</pubDate>
<guid>http://www.--.htm</guid>
</item>
<item>
<title>News Article #2</title>
<link>http://www.--.htm</link>
<description>Whatever new article</description>
<pubDate>Mon, 4 Feb 2008 04:00:00 GMT</pubDate>
<guid>http://www.--.htm</guid>
</item>
</channel>
</rss>
<?xml version="1.0"?>
<rss version="2.0" xmlns:atom="http://-.info/rss/Atom">
<channel>
<title>TITLE</title>
<link>http://-.info/</link>
<description>Whatever Company News</description>
<language>en-us</language>
<pubDate>Mon, 4 Feb 2008 04:00:00 GMT</pubDate>
<lastBuildDate>Mon, 4 Feb 2008 04:00:00 GMT</lastBuildDate>
<docs>http://127.0.0.1/rss</docs>
<generator>Weblog Editor 2.0</generator>
<item>
<title>News Article #1</title>
<link>http://www.--.htm</link>
<description>Whatever new article</description>
<pubDate>Mon, 4 Feb 2008 04:00:00 GMT</pubDate>
<guid>http://www.--.htm</guid>
</item>
<item>
<title>News Article #2</title>
<link>http://www.--.htm</link>
<description>Whatever new article</description>
<pubDate>Mon, 4 Feb 2008 04:00:00 GMT</pubDate>
<guid>http://www.--.htm</guid>
</item>
</channel>
</rss>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
No, you should not run the code (obviously untested and incomplete). You would need to adapt it to your specific application needs. You can learn more about RSS here:
http://cyber.law.harvard.edu/rss/rss.html
If you already have the data base set up, and you can post the CREATE TABLE statements for the relevant table(s) we may be able to show you a better code example. But it may take a long time since we do not have your test data!
http://cyber.law.harvard.edu/rss/rss.html
If you already have the data base set up, and you can post the CREATE TABLE statements for the relevant table(s) we may be able to show you a better code example. But it may take a long time since we do not have your test data!
ASKER
CREATE TABLE `lastnews` (
`id` int(12) unsigned NOT NULL auto_increment,
`title` varchar(1500) character set utf8 collate utf8_persian_ci NOT NULL,
`code` varchar(100) NOT NULL,
`date` date NOT NULL,
`time` time NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=496 ;
`id` int(12) unsigned NOT NULL auto_increment,
`title` varchar(1500) character set utf8 collate utf8_persian_ci NOT NULL,
`code` varchar(100) NOT NULL,
`date` date NOT NULL,
`time` time NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=496 ;
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Code is actuelly url and title is insted of description here. Title is in persian languge.
OK, if the title column is actually the description, you would probably want to add a column to this table to hold the title. Read over the Harvard link carefully -- it's not perfect, but it is one of the best descriptions of RSS that you can get.
ASKER
I have added the column description (collate utf8_persian_ci) to the table.
I think you might want two tables and a junction table. One would be a channels table. Each channel table would have a one-to-many relationship with the items table. The column definitions would be similar because both channels and items have many characteristics in common, but there is a hierarchy - items belong to channels.
The junction table would contain two columns - the key of the channel row and the key of the item row. Using this table you would be able to associate your channels and items in a "relational" way.
If you're new to web site development using PHP and MySQL, you would probably enjoy this book:
http://www.sitepoint.com/books/phpmysql4/
The junction table would contain two columns - the key of the channel row and the key of the item row. Using this table you would be able to associate your channels and items in a "relational" way.
If you're new to web site development using PHP and MySQL, you would probably enjoy this book:
http://www.sitepoint.com/books/phpmysql4/
ASKER
Hi, I retrieve data from mysql as shows in this way here http://khatesabz.info/, I Will rss to be able to show titles and their links in other websites.
I will make those tables you have mentioned above.
I will make those tables you have mentioned above.
Sounds good. Best of luck with your project, ~Ray
ASKER
The question is what should I do after I make those new tables?
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
ASKER