PHP - How to get images from directory, separate them into pages

I'm trying to get images from a folder and show them in a single page.

<ul>
<?php
foreach(glob('images/*.*') as $singleImg){
    echo '<li><img src="'.$singleImg.'" /></li>';
}
?>
</ul>

but there are hundreds of them.

Is there a way to show them in groups using PHP, JQuery or just Java?

I have 100, and I want to show 20, then click a link/button/scroll to show 20 more. Instead of showing them all at the same time?

Answers


Sure, there are multiple ways of doing it. You could use an Ajax call to get the next/previous 20 images, or keep track of which set of images you are on with a hidden field and post that to the server when the next/previous button is clicked.

The thing you want to AVOID is loading all of them at one time.


Need Your Help

How to make navBar's title located at center?

iphone cocoa-touch

Because the navigationItem.rightBarButtomItem is customized, it will occupy a big place and the title view won't be on the center.

why storyboard ui elements not showing on UIViewController in xcode 6?

ios ios8

I am new to IOS development. I am developing an app for IOS 8 devices. I used storyboard for my design yesterday my storyboard showing all UI design but today morning it show blank UIViewController...