2012-05-07 102 views
0

以下動態rss源語法顯示了具有正確通道輸出的源頁面http://www.site.com.com/rssfeed.php,但它無法從<item> </item>標記中定義的數據庫填充動態數據。動態Rss源無法從數據庫填充數據

<?php require_once('mysqlconnection.php'); ?> 
<?php 
mysql_select_db($database_rssfeed, $rssfeed); 
$query_rssfeed = "SELECT * FROM rssfeed ORDER BY id DESC"; 
$rssfeed = mysql_query($query_rssfeed, $rssfeed) or die(mysql_error()); 
$row_rssfeed = mysql_fetch_assoc($rssfeed); 
$totalRows_rssfeed = mysql_num_rows($rssfeed); 

$rss = '<?xml version="1.0" encoding="utf-8"?> 
<rss version="2.0"> 
<channel> 
<title><![CDATA[Test || Rss Feed]]></title> 
<link>http://www.site.com.com/rssfeed.php</link> 
<description><![CDATA[Rss Feed]]></description> 
<lastBuildDate>'.date('D, d M Y h:i:s O').'</lastBuildDate> 
<docs>http://www.test.com</docs> 
<language>en</language> 
'; 


//Call data within <item> </item> 

while ($row_rssfeed = mysql_fetch_assoc($rssfeed)); { 
$rss .= '<item> 
<title><![CDATA['.$row_rssfeed['title'].']]></title> 
<description><![CDATA['.$row_rssfeed['description'].']]></description> 
<link><![CDATA['.$row_rssfeed['link'].']]></link> 
<pubDate><![CDATA['.$row_rssfeed['date'].']]></pubDate> 
<guid><![CDATA['.$row_rssfeed['link'].']]></guid> 
</item>'; 
} 
//<![CDATA[]]> not to break the XML structure of my feed 
$rss .= '</channel></rss>'; 
header ("content-type: text/xml"); 
echo $rss; //Output the feed to web browser 

mysql_free_result($rssfeed); 
?> 

任何想法?

回答

2

從該行

while ($row_rssfeed = mysql_fetch_assoc($rssfeed)); { 
+0

這是潛意識的一個嚴重錯誤刪除分號。該語法僅將一個數據提取到頁面且沒有日期。謝謝, –