kloon_za
10-23-2006, 06:53 AM
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.
|
Click to See Complete Forum and Search --> : creating a xml file kloon_za 10-23-2006, 06:53 AM 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. knowj 10-23-2006, 11:17 AM thats my rss feed just edit it to do as you want. i use url rewrite for my site so theres a bit of script to make the link in there but change it to what you want also in my .htaccess i have: RewriteEngine on RewriteRule rss.xml$ rss.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> webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |