/    Sign up×
Community /Pin to ProfileBookmark

I need a little help with page numbering

This script takes every image in a folder and shows it on a webpage. Is there a way to show like an simple page number like 1,2,3,4,5 every 10 images or so? I try to google some things but all I can find is with a database. Is it even possible with an array? I am not the best in php so plz help!.

[CODE] # Show only these file types in the image folder
$imagetypes = ‘{*.jpg,*.JPG,*.JPEG,*.png,*.PNG,*.gif,*.GIF}’;
# Add images to array
$images = glob($imagefolder.$imagetypes, GLOB_BRACE);
# Sort the images based on its ‘last modified’ time stamp
$sortedImages = array();
$count = count($images);
for ($i = 0; $i < $count; $i++) {
$sortedImages[date (‘YmdHis’, filemtime($images[$i])).$i] = $images[$i];
}

# Set to ‘false’ if you want the oldest images to appear first
$newest_images_first = true;
# Sort images in array
if($newest_images_first) {
krsort($sortedImages);
} else {
ksort($sortedImages);
}

# Generate the HTML output
writeHtml(‘<ul class=”ins-imgs”>’);
foreach ($sortedImages as $image) {
# Get the name of the image, stripped from image folder path and file type extension
$name = ‘Image name: ‘.substr($image,strlen($imagefolder),strpos($image, ‘.’)-strlen($imagefolder));
# Get the ‘last modified’ time stamp, make it human readable
$last_modified = ‘(last modified: ‘.date(‘F d Y H:i:s’, filemtime($image)).’)’;
# Begin adding
writeHtml(‘<li class=”ins-imgs-li”>’);
writeHtml(‘<div class=”ins-imgs-label”>’.$name.’ ‘.$last_modified.'</div>’);
writeHtml(‘<div class=”ins-imgs-img”><a name=”‘.$image.'” href=”#’.$image.'”>’);
writeHtml(‘<img src=”‘.$image.'” alt=”‘. $name.'” title=”‘. $name.'”>’);
writeHtml(‘</a></div>’);
writeHtml(‘</li>’);
}
writeHtml(‘</ul>’);
writeHtml(‘<link rel=”stylesheet” type=”text/css” href=”ins-imgs.css”>’);
# Convert HTML to JS
function writeHtml($html) {
echo “document.write(‘”.$html.”‘);n”;

}

?>[/CODE]

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @Dylan_rz spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.22,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...