<?php
include "/config/koneksi.php"; // koneksi ke database

// Ambil provider dari URL
$provider = isset($_GET['provider']) ? $_GET['provider'] : '';

// Query game sesuai provider
$sql = "SELECT * FROM tb_games WHERE provider = '$provider' ORDER BY game_name ASC";
$result = mysqli_query($koneksi, $sql);

// Jika tidak ada game
if (mysqli_num_rows($result) == 0) {
    echo "<p style='text-align:center;'>⚠️ Tidak ada game untuk provider ini.</p>";
} else {
    echo "<div class='games-grid'>";
    while ($row = mysqli_fetch_assoc($result)) {
        echo "
        <div class='game-card'>
            <a href='play.php?game=" . $row['game_code'] . "'>
                <figure>
                    <img src='" . $row['image_url'] . "' alt='" . $row['game_name'] . "'>
                </figure>
                <figcaption>" . $row['game_name'] . "</figcaption>
            </a>
        </div>
        ";
    }
    echo "</div>";
}
?>
