<?php
# Settings
$productsPerPage=12;

# Set Access to the database
mysql_select_db("products",$conn);
# --------------------------GENERATE THE RSS 2.0 FEED ----------------------------------
header("Content-type: text/xml");
echo "<?xml version='1.0' encoding='UTF-8'?>";
?>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.84"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.google.com/schemas/sitemap/0.84
http://www.google.com/schemas/sitemap/0.84/sitemap.xsd">
<?php
# get active tags
$sql = "SELECT * FROM tags WHERE STATUS = 'active' AND  active_items > 0 ORDER BY tag  ASC ";
$tagsResult=mysql_query($sql,$conn) or die(mysql_error());
# for each tag count the active taggings and update the tag record
while ($r = mysql_fetch_array($tagsResult)) {
	$tag = $r['tag'];
	$items=$r['active_items'];
	$offset=0;
	$offset = $offset + $productsPerPage;
	$url=sprintf("http://www.speaktomecatalog.com/room.php?tag=%s",$tag);
?>
<url>
      <loc><?php echo $url ?></loc>
      <changefreq>daily</changefreq>
      <priority>0.9 </priority>
</url>
<?php
while ($offset<$items){
	$url=sprintf("http://www.speaktomecatalog.com/room.php?tag=%s&offset=%s",$tag,$offset);	
	$url=htmlspecialchars($url);	
?>
<url>
      <loc><?php echo $url ?></loc>
      <changefreq>daily</changefreq>
      <priority>0.9</priority>
</url>
<?php 
	$offset = $offset + $productsPerPage;
	}
} 
$sql = 	"SELECT * FROM product 
	WHERE varietyof = '' AND 
	activated > 0 
	ORDER BY item";
$result=mysql_query($sql,$conn) or die(mysql_error()); 
while ($r = mysql_fetch_array($result)) {
	$item=$r['item'];
	$url=sprintf("http://www.speaktomecatalog.com/individual.php?item=%s",$item);
?>
<url>
      <loc><?php echo $url ?></loc>
      <changefreq>weekly</changefreq>
      <priority>0.5</priority>
</url>

<?php } ?>

<url>
      <loc>http://www.speaktomecatalog.com/</loc>
      <changefreq>daily</changefreq>
      <priority>0.9</priority>
</url>
<url>
      <loc>http://www.speaktomecatalog.com/contacts.html</loc>
      <changefreq>yearly</changefreq>
      <priority>0.3</priority>
</url>
<url>
      <loc>http://www.speaktomecatalog.com/shipping.html</loc>
      <changefreq>yearly</changefreq>
      <priority>0.3</priority>
</url>
<url>
      <loc>http://www.speaktomecatalog.com/policies.html</loc>
      <changefreq>yearly</changefreq>
      <priority>0.3</priority>
</url>
<url>
      <loc>http://www.speaktomecatalog.com/getCatalog.html</loc>
      <changefreq>yearly</changefreq>
      <priority>0.3</priority>
</url>
<url>
      <loc>http://www.speaktomecatalog.com/wholesale/</loc>
      <changefreq>monthly</changefreq>
      <priority>0.3</priority>
</url>
<url>
      <loc>http://www.speaktomecatalog.com/promotion.html</loc>
      <changefreq>yearly</changefreq>
      <priority>0.3</priority>
</url>
<url>
      <loc>http://www.speaktomecatalog.com/talent/</loc>
      <changefreq>monthly</changefreq>
      <priority>0.3</priority>
</url>
</urlset>

