duanpin9531 2014-04-16 16:37
浏览 50

如何使用PHP在我的RSS Feed中添加不同的图像

i want to add images dynamically in my rss feed but its only showing thumbs then it disappear see the sample here

my images are stored on my server at a folder called "allimages" and all pages are retrieved from mysql database. where em i wrong!!!?

Any help ll be appreciated thaanx below is my code

 <?php
header("Content-type: text/xml");
$connection = mysql_connect( "------", "-----", "-----");
mysql_select_db("-------", $connection);
$sundo = "SELECT * FROM NEWSPAGES ORDER BY ID DESC LIMIT 20";
$query = mysql_query($sundo ) or die(mysql_error());

echo (" <rss version=\"2.0\"> ");
echo (" <channel> ");
echo (" <title>People</title>");
echo (" <link>http://tabata.com</link>");
echo (" <description>tabata</description> ");
echo " <copyright>Copyright 2013</copyright> 
";
echo " <managingEditor>tabata(sun)</managingEditor> 
";
echo " <webMaster>tabata.com (sun)</webMaster> 
";
echo (" <language>IT- en</language>");
while($array = mysql_fetch_array( $query )) {
extract($array);
echo "<item>
<title>$title</title>
<link>http://tabata.com/news.php?page=$id</link>
<description><![CDATA[<img src=\"http://tabata.com/$allimages\" width=\"57\" height=\"57\" />]]>$description</description>
<image>
<link>http://tabata.com/news.php?page=$id</link>
<url>http://tabata.com/$allimages</url>
<title>$title</title>
</image>
</item>";
}
echo " </channel> </rss>" ;

?>

  • 写回答

2条回答 默认 最新

  • dongmo9996 2014-04-16 16:50
    关注

    Save image names/full url in you database, create a column of images let say images. Then in you while loop you can get images like $array['images']. Like <image> ... <url>http://tabata.com/$array['images']</url> ... </image> Like for page http://tabelltz.com/news.php?page=31 you image column should have img name 27.jpg and url like <url>http://tabata.com/userfiles/$images</url> I use $images as you're using extract($array); Better if you don't use extract($array);

    评论

报告相同问题?