<?php
include_once("includes/db_connect.php");
header("Content-Type: application/xml; charset=utf-8");
function x($value){ return htmlspecialchars((string)$value, ENT_XML1, 'UTF-8'); }
echo '<?xml version="1.0" encoding="UTF-8"?>';
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url><loc>https://suredeals.co.ke/</loc><changefreq>daily</changefreq><priority>1.0</priority></url>
  <url><loc>https://suredeals.co.ke/on-offer</loc><changefreq>daily</changefreq><priority>0.8</priority></url>
<?php
$cats = mysqli_query($con, "SELECT url FROM category WHERE status='1'");
while($c = mysqli_fetch_assoc($cats)) { ?>
  <url><loc>https://suredeals.co.ke/products/<?php echo x($c['url']); ?></loc><changefreq>weekly</changefreq><priority>0.8</priority></url>
<?php }
$products = mysqli_query($con, "SELECT producturl FROM products WHERE status='1' ORDER BY id DESC");
while($p = mysqli_fetch_assoc($products)) { ?>
  <url><loc>https://suredeals.co.ke/product/<?php echo x($p['producturl']); ?></loc><changefreq>weekly</changefreq><priority>0.9</priority></url>
<?php } ?>
</urlset>
