Can anybody help me, is there a way of creating an xml file using php? I want to create a rss feed that updates dynamically every time the database has been updated.
[code=php]<? require_once "connection.php"; header("Content-Type: text/xml"); echo '<?xml version="1.0" encoding="UTF-8"?>'." n"; /* echo '<?xml-stylesheet title="XSL_formatting" type="text/xsl" href="rss.xsl"?>'." n"; */ ?> <rss version="2.0"> <channel> <title>bog</title> <link>http://www.url</link> <description>some description</description> <? $query = "SELECT * FROM some table ORDER BY somekey DESC LIMIT 15"; $result = mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_assoc($result)) { $year = substr($row['date'], 0, 4); $month = substr($row['date'], 5, 2); $row['blog_title'] = stripslashes($row['blog_title']); echo "<item> n"; echo "<title>".$row['sometitle']."</title> n"; echo "<link>http://url/".$year."/".$month."/</link> n"; echo "<description>Blog Entry: ".$row['somedate']."</description> n"; echo "</item> n"; echo "n"; } ?> </channel> </rss>[/code]
some table
Help @kloon_za spread the word by sharing this article on Twitter...