I want to make a pagination to my pictures from database. Anything i tried doesnt worked, i have no idea what to do. Someone can explain it for me? Watched many tutorial and still cant find a solution (im beginner ye).
<?php
// Connect to MySQL
$pdo = pdo_connect_mysql();
// MySQL query that selects all the images
$stmt = $pdo->query('SELECT * FROM images ORDER BY uploaded_date DESC');
$images = $stmt->fetchAll(PDO::FETCH_ASSOC);
?>
<div class="content home">
<h2>Gallery</h2>
<p>Welcome to the gallery page, you can view the list of images below.</p>
<div class="images">
<?php foreach ($images as $image): ?>
<?php if (file_exists($image['path'])): ?>
<a href="#">
<img src="<?=$image['path']?>" alt="<?=$image['description']?>" data-id="<?=$image['id']?>" data-title="<?=$image['title']?>" width="300" height="200">
<span><?=$image['description']?></span>
</a>
<?php endif; ?>
<?php endforeach; ?>
</div>
<div class="container">
<ul class="pagination">
<li class="page-item"><a class="page-link" href="#">Previous</a></li>
<li class="page-item"><a class="page-link" href="#">1</a></li>
<li class="page-item"><a class="page-link" href="#">2</a></li>
<li class="page-item"><a class="page-link" href="#">3</a></li>
<li class="page-item"><a class="page-link" href="#">Next</a></li>
</ul>
</div>
</div>