Merhaba sevgili Webmaster Kenti okurları;
Bugün size php ile dinamik rss oluşturmayı anlatıcam. Mysql'den veri çekerek dinamik bir şekilde rss oluşturmak php ile çok basittir. Verdiğim kodu kendinize göre değiştirip kullanabilirsiniz.
Örnek Kod:
<?php
include "config.php";
header('Content-Type: text/xml');
echo '<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<channel>
<title>Webmaster Kenti</title>
<description>Hayattan Kopamayan Blog </description>
<link>http://webmasterkenti.blogspot.com/</link>';
$sorgu = mysql_query("SELECT id, baslik, icerik, tarih FROM yazilar ORDER BY mid DESC LIMIT 15");
while($icerik=mysql_fetch_array($sorgu)){
echo '
<item>
<title>'.$icerik['baslik'].'</title>
<description><![CDATA[
'.$icerik['icerik'].'
]]></description>
<link>http://webmasterkenti.blogspot.com/comments.php?entry=entry'.$icerik['id'].'</link>
<pubDate>'.$icerik['tarih'].' GMT</pubDate>
</item>';
}
echo '</channel>
</rss>';
?>
Hiç yorum yok:
Yorum Gönder