如何使用php在我的RSS提要中添加不同的图像 [英] how to add different images in my rss feed using php

查看:35
本文介绍了如何使用php在我的RSS提要中添加不同的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的 rss 提要中动态添加图像,但它只显示拇指然后它消失见示例 here

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

我的图像存储在我的服务器上一个名为allimages"的文件夹中,所有页面都从 mysql 数据库中检索.我哪里错了!!!?

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> \ n";
echo " <managingEditor>tabata(sun)</managingEditor> \ n";
echo " <webMaster>tabata.com (sun)</webMaster> \ n";
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>" ;

?>

推荐答案

在你的数据库中保存图像名称/完整 url,创建一列图像,比如 images.然后在你的 while 循环中你可以得到像 $array['images'] 这样的图像.喜欢<代码><图像>...<url>http://tabata.com/$array['images']</url>...</图像>就像页面 http://tabelltz.com/news.php?page=31 你的图片列应该有 img 名称 27.jpg和网址一样http://tabata.com/userfiles/$images我使用 $images,因为您使用的是 extract($array);最好不要使用 extract($array);

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);

这篇关于如何使用php在我的RSS提要中添加不同的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆