<?php
include_once("include/main.inc.php");

$offset = intval($_POST['offset']);
$limit = intval($_POST['limit']);
$catID = intval($_POST['catID']);
$targetlocation = isset($_POST['targetlocation']) ? htmlspecialchars($_POST['targetlocation']) : '';

$sql = "SELECT * FROM catgallery_tbl WHERE FIND_IN_SET('$catID', gallery_cat) ORDER BY id ASC LIMIT $offset, $limit";
$result = mysqli_query($GLOBALS['dbconn'], $sql);

while($row = mysqli_fetch_assoc($result)){ ?>
    <div class="col gallery-item">
        <div class="gallery-bx">
            <a data-fancybox="" href="<?=site_url;?>/uploaded-files/cat-gallery/<?=$row['gallery_image'];?>" 
                title="<?= $row['gallery_title']; ?> in <?=$targetlocation;?>" class="img">
                <img src="<?=site_url;?>/uploaded-files/cat-gallery/<?=$row['gallery_image'];?>" alt="<?= $row['gallery_title']; ?>" in <?=$targetlocation;?> title="<?= $row['gallery_title']; ?> in <?=$targetlocation;?>">
            </a>
        </div>
    </div>
<?php } ?>
