<?php
header("Content-type: text/xml");
require_once 'db_connect.php'; 
$base_url = "https://swo.vn";

echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
// Home
echo '<url><loc>' . $base_url . '/</loc><changefreq>daily</changefreq><priority>1.0</priority></url>';
// Services
try {
    $services = $db->query("SELECT id FROM services ORDER BY id DESC");
    while ($row = $services->fetch(PDO::FETCH_ASSOC)) {
        echo '<url><loc>' . $base_url . '/detail.php?id=' . $row['id'] . '</loc><changefreq>weekly</changefreq><priority>0.8</priority></url>';
    }
} catch (Exception $e) {}
echo '</urlset>';
?>