<?php
require_once '../config.php';
require_once '../app/includes/constant.php';
require_once '../app/includes/app_start.php';

$page = $_POST['page'] ?? 1;
$category = $_POST['category'] ?? '';
$limit = 30;
$row = ($page - 1) * $limit;

$query = "SELECT * from zon_games WHERE game_category='$category' order by id asc limit $row,$limit";
$run = mysqli_query($con, $query);
if (num_rows(T_ZON_GAMES, "game_category='$category'") > 0) {
while ($game = mysqli_fetch_assoc($run)) { ?>
    <div class="rounded-lg wow <?php echo $zon['config']['animate_class'] ?> ">
        <div class="game-card w-full">
            <a href="<?php echo $site_url . 'game/' . makeSlug($game['game_name']) . '/' . $game['id'] ?>"><img src="<?php echo $game['game_banner_url'] == '' ? $game['game_image_url'] : $game['game_banner_url'] ?>" /></a>
            <div class="game-details gap-4">
                <a href="<?php echo $site_url . 'game/' . makeSlug($game['game_name']) . '/' . $game['id'] ?>" class="text-md line-clamp-2 font-semibold">
                    <?= $game['game_name'] ?>
                </a>
                <a style="color: var(--zon-muted-color);" class="text-sm" href="<?php echo $site_url ?>category/?n=<?= urlencode($game['game_category']) ?>"><?= $game['game_category'] ?></a>
            </div>
        </div>
    </div>
<?php }
} else {
    echo "There are no games in this category right now.";
 } ?>