PHP学会网 php培训网 PHP暑期培训 PHP寒假培训 PHP假期培训 » web2.0 » 生成rss的一个例子
本页主题: 生成rss的一个例子 打印 | 加为IE收藏 | 收藏主题 | 上一主题 | 下一主题

admin



该用户目前不在线
级别: 新手上路
精华: 0
发帖: 0
威望: -1 点
金钱: -10 PYMB
贡献值: 0 点
在线时间:0(小时)
注册时间:2005-09-27
最后登录:2007-08-26

生成rss的一个例子


顶端 Posted: 2005-09-22 13:07 | [楼 主]
admin



该用户目前不在线
级别: 新手上路
精华: 0
发帖: 0
威望: -1 点
金钱: -10 PYMB
贡献值: 0 点
在线时间:0(小时)
注册时间:2005-09-27
最后登录:2007-08-26

生成rss的一个例子


osc上所有的外挂,但是我们可以从中学得如何生成RSS
非常简单实用哦!

#################################################################
# $Id: rss-news.php,v 1.0 2004/03/22 12:00:00 phv Exp $ #
# osCommerce, Open Source E-Commerce Solutions #
# [url]http://www.oscommerce.com[/url] #
# Copyright (c) 2004 Tom Nitzschner ([url]http://www.toms-home.com)[/url] #
# Released under the GNU General Public License #
#################################################################

#######################################################################
# This rss news feed cript gets a defined count of new items from the #
# system database and displays them to the rss news reader software. #
# The only items you should have to edit are the system values right #
# below this block. #
#######################################################################

################################
# Edit these to suit your site #
################################

$Title = "ThailandWholesales"; //Enter an appropriate title for your website
$SiteLink = "http://www.thailandwholesales.com"; //Enter your main shopping cart link
$Description = "Bringing wholesale products at factory direct prices to you."; //Enter a description of your site
#$blank_image = ""; //Enter name of your place holder (blank) image - leace at '' if no image is used
$product_count = 10;

##################
# End of editing #
##################

###########################################
# Start to generate the xml/rss feed page #
###########################################
require('includes/application_top.php');
header("Content-Type: text/xml");
echo "

";
echo "";
echo " "http://my.netscape.com/publish/formats/rss-0.91.dtd">

";
echo "

";
echo "
";
echo "$Title";
echo "$SiteLink";
echo "$Description";

###########################################
# SQL to select the required product rows #
###########################################
$count = 1;
$query="select products_id, products_image, products_tax_class_id, products_price from " . TABLE_PRODUCTS . " where products_status='1' and products_image!='$blank_image' order by products_date_added desc limit $product_count";
$product_query = tep_db_query($query);
$num_rows = tep_db_num_rows($product_query);
if ($num_rows < $product_count) {
$product_count = $num_rows;
}
#####################################
# Loop to get the required products #
#####################################
while ($count < $product_count) {
tep_db_data_seek($product_query, $count);
$next_product = tep_db_fetch_array($product_query);
$next_product['products_name'] = tep_get_products_name($next_product['products_id']);
$next_product['specials_new_products_price'] = tep_get_products_special_price($next_product['products_id']);
if (tep_not_null($next_product['specials_new_products_price'])) {
$price = $currencies->display_price($next_product['specials_new_products_price'], tep_get_tax_rate($next_product['products_tax_class_id']));
} else {
$price = $currencies->display_price($next_product['products_price'], tep_get_tax_rate($next_product['products_tax_class_id']));
}
$link = HTTP_SERVER . DIR_WS_CATALOG;
$link .= "product_info.php?products_id=" . $next_product['products_id'];
$linkimage = HTTP_SERVER . DIR_WS_CATALOG .DIR_WS_IMAGES;
$linkimage .= $next_product['products_image'];
echo "";
echo "".$next_product['products_name']."";
echo "$linkimage; ";
echo "$link; ";
echo "";
echo " ";
echo "";
echo "".$next_product['products_name']."";
echo "$link; ";
echo "Item Price: $price ";
echo "
";
$count++;
}
###################################################
# Finished looping, now close of the xml/rss page #
###################################################
echo "
";
echo "";
echo "Search";
echo "Search Products";
echo "keywords";
echo "$SiteLink/advanced_search_result.php";
echo "
";
echo " ";
echo "
";
?>
顶端 Posted: 2005-09-22 13:07 | 1 楼
PHP学会网 php培训网 PHP暑期培训 PHP寒假培训 PHP假期培训 » web2.0

时:11-22 18:50 Copyright © 2006 phpwhy.com 权
ICP05060669

曳息 -