/    Sign up×
Community /Pin to ProfileBookmark

creating a xml file

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.

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@knowjOct 23.2006 — 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

[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]
×

Success!

Help @kloon_za spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...