<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <!-- Homepage -->
    <url>
        <loc>https://nkbgaming.com/</loc>
        <lastmod>2025-02-22</lastmod>
        <changefreq>daily</changefreq>
        <priority>1.0</priority>
    </url>

    <!-- Static Pages -->
    <url>
        <loc>https://nkbgaming.com/latest-gaming-laptops.php</loc>
        <lastmod>2025-02-22</lastmod>
        <changefreq>daily</changefreq>
        <priority>0.8</priority>
    </url>
    <url>
        <loc>https://nkbgaming.com/upcoming-gaming-laptops.php</loc>
        <lastmod>2025-02-22</lastmod>
        <changefreq>daily</changefreq>
        <priority>0.8</priority>
    </url>
    
    
    
    <url>
        <loc>https://nkbgaming.com/games/</loc>
        <lastmod>2025-02-22</lastmod>
        <changefreq>daily</changefreq>
        <priority>0.8</priority>
    </url>
    
    
    <url>
        <loc>https://nkbgaming.com/games/compare.php</loc>
        <lastmod>2025-02-22</lastmod>
        <changefreq>daily</changefreq>
        <priority>0.8</priority>
    </url>
    
    
    
    <url>
        <loc>https://nkbgaming.com/games/game.php</loc>
        <lastmod>2025-02-22</lastmod>
        <changefreq>daily</changefreq>
        <priority>0.8</priority>
    </url>
    
    

    <!-- Brand Pages (Dynamic) -->
    <?php
    include_once 'db_connection.php';
    $brandQuery = "SELECT * FROM brands ORDER BY id DESC LIMIT 12";
    $brandResult = mysqli_query($conn, $brandQuery);
    if ($brandResult && mysqli_num_rows($brandResult) > 0) {
        while ($brand = mysqli_fetch_assoc($brandResult)) {
            $brandSlug = generateSlug($brand['name']);
            $brandUrl = "https://nkbgaming.com/gaming-laptops/{$brandSlug}-brand/";
            // Assuming lastmod could be updated from a database field; using current date as fallback
            $lastMod = '2025-02-22'; // Replace with $brand['last_updated'] if available
            echo "<url>\n";
            echo "    <loc>" . htmlspecialchars($brandUrl) . "</loc>\n";
            echo "    <lastmod>{$lastMod}</lastmod>\n";
            echo "    <changefreq>weekly</changefreq>\n";
            echo "    <priority>0.7</priority>\n";
            echo "</url>\n";
        }
    }
    ?>

    <!-- Featured Products (Dynamic) -->
    <?php
    $featuredQuery = "SELECT * FROM products WHERE status = 'active' ORDER BY date_added DESC LIMIT 8";
    $featuredResult = mysqli_query($conn, $featuredQuery);
    if ($featuredResult && mysqli_num_rows($featuredResult) > 0) {
        while ($product = mysqli_fetch_assoc($featuredResult)) {
            $productSlug = generateSlug($product['name']);
            $productUrl = "https://nkbgaming.com/{$productSlug}";
            $lastMod = date('Y-m-d', strtotime($product['date_added']));
            echo "<url>\n";
            echo "    <loc>" . htmlspecialchars($productUrl) . "</loc>\n";
            echo "    <lastmod>{$lastMod}</lastmod>\n";
            echo "    <changefreq>weekly</changefreq>\n";
            echo "    <priority>0.6</priority>\n";
            echo "</url>\n";
        }
    }
    ?>

    <!-- Latest Gaming Laptops (Dynamic) -->
    <?php
    $latestLaptopsCategoryId = 16;
    $latestQuery = "SELECT * FROM products WHERE status = 'active' AND category_id = ? ORDER BY date_added DESC LIMIT 8";
    $latestStmt = $conn->prepare($latestQuery);
    if ($latestStmt) {
        $latestStmt->bind_param("i", $latestLaptopsCategoryId);
        $latestStmt->execute();
        $latestResult = $latestStmt->get_result();
        while ($laptop = mysqli_fetch_assoc($latestResult)) {
            $productSlug = generateSlug($laptop['name']);
            $productUrl = "https://nkbgaming.com/{$productSlug}";
            $lastMod = date('Y-m-d', strtotime($laptop['date_added']));
            echo "<url>\n";
            echo "    <loc>" . htmlspecialchars($productUrl) . "</loc>\n";
            echo "    <lastmod>{$lastMod}</lastmod>\n";
            echo "    <changefreq>weekly</changefreq>\n";
            echo "    <priority>0.6</priority>\n";
            echo "</url>\n";
        }
        $latestStmt->close();
    }
    ?>

    <!-- Upcoming Gaming Laptops (Dynamic) -->
    <?php
    $upcomingLaptopsCategoryId = 14;
    $upcomingQuery = "SELECT * FROM products WHERE status = 'active' AND category_id = ? ORDER BY date_added DESC LIMIT 8";
    $upcomingStmt = $conn->prepare($upcomingQuery);
    if ($upcomingStmt) {
        $upcomingStmt->bind_param("i", $upcomingLaptopsCategoryId);
        $upcomingStmt->execute();
        $upcomingResult = $upcomingStmt->get_result();
        while ($laptop = mysqli_fetch_assoc($upcomingResult)) {
            $productSlug = generateSlug($laptop['name']);
            $productUrl = "https://nkbgaming.com/{$productSlug}";
            $lastMod = date('Y-m-d', strtotime($laptop['date_added']));
            echo "<url>\n";
            echo "    <loc>" . htmlspecialchars($productUrl) . "</loc>\n";
            echo "    <lastmod>{$lastMod}</lastmod>\n";
            echo "    <changefreq>weekly</changefreq>\n";
            echo "    <priority>0.6</priority>\n";
            echo "</url>\n";
        }
        $upcomingStmt->close();
    }
    ?>

</urlset>