Reputation: 25733
How to create pagination script with out database support,
i have 200 images in my images folder,
i want to display these images with pagination ,
if DB means we use some count to we can create pagination , but its clearly mentioned no database, so how to create the pagination ,
Upvotes: 0
Views: 7635
Reputation: 29462
Exapmle code:
$images = glob('img/*.jpg');
$img_count = count($images);
$per_page = 10;
$max_pages = ceil($img_count / $per_page);
$show = array_slice($images, $per_page * intval($_GET['page']) - 1, $per_page);
if($_GET['page'] > 1)
$prev_link = '<a href="images.php?page='.($_GET['page']-1).'"> previous </a>';
if($_GET['page'] < $max_pages)
$next_link = '<a href="images.php?page='.($_GET['page']+1).'"> next </a>';
Upvotes: 2
Reputation: 10880
You can read all of the image names in the directory into an array, maybe using opendir
. Then use this array as your database.
Upvotes: 0