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 Quote Link to comment 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 Quote Link to comment 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>you@youremail.com</managingEditor> <webMaster>you@youremail.com</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; ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.