Andrew R Posted February 17, 2009 Share Posted February 17, 2009 Hello Does anyone know of a good script that take data from a MYSQL database and displays it in an RSS feed? Many thanks Link to comment https://forums.phpfreaks.com/topic/145539-phpmysql-rss/ Share on other sites More sharing options...
Mchl Posted February 17, 2009 Share Posted February 17, 2009 I know one. I made it for myself. It is... oh my... 96 lines long, and uses mostly xmlwriter Link to comment https://forums.phpfreaks.com/topic/145539-phpmysql-rss/#findComment-764074 Share on other sites More sharing options...
cola Posted February 17, 2009 Share Posted February 17, 2009 Here u some rss which i made. I hope that will help you. <?php $host = "localhost"; $database = "db"; $user = "root"; $password ="k" ; $sqlcon = mysql_connect($host, $user, $password) or die ("Can not connect to server"); mysql_select_db($database) or die ("Can not connect to database") ; $query = "select * from news order by id desc limit 10 "; $result = mysql_query($query, $sqlcon); while ($line = mysql_fetch_assoc($result)) { $return[] = $line; } $now = date("D, d M Y H:i:s T"); $output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <rss version=\"2.0\"> <channel> <title>MY RSS</title> <link>http://www.site/rss.php</link> <description></description> <language>en-EN</language> <pubDate>$now</pubDate> <lastBuildDate>$now</lastBuildDate> <docs>http://novosarajevo.ba</docs> <managingEditor>[email protected]</managingEditor> <webMaster>[email protected]</webMaster>"; foreach ($return as $line) { $title = $line[title]; $flash = $line[flash]; $date=$line[year]."-".$line[month]."-".$line[day]; $condate = date("D,j M Y", strtotime($date)); $time =$line[ 'time']; $time = explode(":", $time); $conhour=$time[0]-2; $contime = $conhour.":".$time[1].":".$time[2]; $output .= "<item> <title>".$title."</title> <link>http://site.com?pid=".htmlentities($line['id'])."</link> <description>".$flash."</description> <pubDate>".$condate." ". $contime." +0000 </pubDate> </item>"; } $output .= "</channel></rss>"; echo $output; ?> Link to comment https://forums.phpfreaks.com/topic/145539-phpmysql-rss/#findComment-764109 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.