<?php
include('config.php');

if (isset($_POST['block_id'])) {
    $blockId = intval($_POST['block_id']); // Get the block ID from the POST request

    // Query to fetch games based on block ID
    $games = $db->getRows("SELECT * FROM game WHERE block_id = $blockId ORDER BY id ASC");

    if (!empty($games)) {
        foreach ($games as $game) {
            echo '<option value="1">Select Game</option>';
            echo '<option value="' . $game['game_name'] . '">' . $game['game_name'] . '</option>';
        }
    } else {
        echo '<option value="0">No games found</option>';
    }
} else {
    echo '<option value="0">Invalid request</option>';
}
?>