<?php
include "./db.php"; 
include "x.php"; 
$limit = 12;

$page = isset($_POST['page']) ? (int) $_POST['page'] : 1;
$offset = ($page - 1) * $limit;

$sql = "SELECT * FROM data_table 
        WHERE up_by = '$x' 
        AND page_type = 'gallery' 
        AND recycle = '1' 
        ORDER BY id DESC 
        LIMIT $limit OFFSET $offset";

$result = mysqli_query($con, $sql);

if ($result && mysqli_num_rows($result) > 0) {
    $c = $offset + 1;
    while ($row = mysqli_fetch_assoc($result)) {
?>
<div class="col-md-4 wow fadeInUp" data-wow-delay=".<?php echo $c; ?>5s">
    <div class="gallery-item">
        <div class="gallery-img">
            <img src="./login/upload/<?php echo $row['image_one']; ?>" alt="">
        </div>
        <div class="gallery-content">
            <a class="popup-img gallery-link" href="./login/upload/<?php echo $row['image_one']; ?>"><i
                    class="fal fa-plus"></i></a>
        </div>
    </div>
</div>
<?php
        $c++;
    }
} else {
    echo "no_more"; // signal end
}
?>