<?php header("Content-Type: application/xml");  ?>
<?php printf('<?xml version="1.0"  encoding="iso-8859-1" ?> '); ?>

<?php
require_once('Connections/watches.php');
require_once('includes/functions.inc.php');
function rssTime($dt) { 
    $yr=strval(substr($dt,0,4)); 
    $mo=strval(substr($dt,5,2)); 
    $da=strval(substr($dt,8,2)); 
    $hr=strval(substr($dt,11,2)); 
    $mi=strval(substr($dt,14,2)); 
    return date("D, d M Y H:i:s", mktime ($hr,$mi,0,$mo,$da,$yr))." 3600"; 
} 

// begin Recordset
$query_bestsellingwatches = "SELECT products.products_id, products.products_image, products.products_price, products.products_date_added,  products.products_ordered, products_description.products_name, 100 - ( (products.products_price * 1.175) / (products.products_rrp) * 100) AS saving, products.products_price, products.products_rrp, products_description.products_description FROM products, products_description WHERE products_description.products_id = products.products_id AND products.products_status = 1 AND products_description.language_id =1 ORDER BY ((products.products_price * 1.175) / (products.products_rrp ) * 100) LIMIT 0, 20";
$bestsellingwatches = $watches->SelectLimit($query_bestsellingwatches) or die($watches->ErrorMsg());
$totalRows_bestsellingwatches = $bestsellingwatches->RecordCount();
// end Recordset

 //PHP ADODB document - made with PHAkt 2.0.60
 
function feedDesc($text) { 
	$text = str_replace(" & "," and ",$text);
	$text = str_replace("�","'",$text);
	$text = strip_tags($text);
	$text = str_replace("?","",$text);
	$text = str_replace("�","",$text);
	$text = str_replace("&pound;","",$text);
	$text = str_replace("?","",$text);
	
	return $text; 
}
 
 
?>



<rss version="2.0">
   <channel>
      <title>Find Watches Current Best Sellers</title>
      <link>http://www.findwatches.co.uk</link> 
	  <description>Current biggest savings available from Find Watches</description>
	  <pubDate><?php echo date("D, d M Y H:i:s",time())." 3600"; ?></pubDate>
		
		<?php // repeat
		  while (!$bestsellingwatches->EOF) {
		?>
		
		
			<item> 
				<title><?php echo str_replace("&","and",$bestsellingwatches->Fields('products_name')); ?></title>
				<link>http://www.findwatches.co.uk/product_info.php?products_id=<?php echo $bestsellingwatches->Fields('products_id'); ?></link>
				<description><?php echo feedDesc($bestsellingwatches->Fields('products_description')); ?></description>
				<guid isPermaLink="true">http://www.findwatches.co.uk/product_info.php?products_id=<?php echo $bestsellingwatches->Fields('products_id'); ?></guid>
			</item>



<?php
    $bestsellingwatches->MoveNext();
  }
?>
</channel>
  </rss>