i have a page that uses glob to display images that is inside a folder. The thing is, i want to display only 20 pics per page. The tutorials about pagination that i found online is related with database, but i did not use database inside my code.
$files = glob("uploaded_files/*.*");
usort($files, function ($a, $b) {
return filemtime($b) - filemtime($a);
});
foreach ($files as $file) {
echo "<img src='$file' style='height:180px;width:180px; border:2px solid black; margin:20px 0px 10px 10px; *margin:10px 0px 10px 20px;'>";
}
this is my code. how can i make it so that it displays 20 images per page and auto paginate? tq
But here the problem is that every time $files load all the files then it filters.
Added a simple pagination.
This is code that i used for same purpose.
You can use this code after little bit modification according to your CSS and page url and directory location.It Works perfectly fine.Good luck