<?php
// Set the header to XML
header("Content-Type: application/xml; charset=utf-8");

// Connect to your database
$conn = new mysqli("localhost", "username", "password", "database");

echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';

// 1. Add Static Pages (Home, Contact, etc.)
echo '<url><loc>https://www.seller.gbt21c.com/</loc><priority>1.0</priority></url>';

// 2. Fetch Products from Database
$query = "SELECT product_id, updated_at FROM products WHERE status = 'active'";
$result = $conn->query($query);

while($row = $result->fetch_assoc()) {
    echo '<url>';
    // Adjust this URL to match your actual product link structure
    echo '<loc>https://www.seller.gbt21c.com/product_display.php?id=' . $row['product_id'] . '</loc>';
    echo '<lastmod>' . date('Y-m-d', strtotime($row['updated_at'])) . '</lastmod>';
    echo '<changefreq>weekly</changefreq>';
    echo '<priority>0.8</priority>';
    echo '</url>';
}

echo '</urlset>';
?>