Jump to content

Pagination on Images from Directory


LuckyBambu

Recommended Posts

[code]<?
$path = 'images';
$i = 0;
$imgDir = opendir ($path);
while ( $file = readdir( $imgDir ) )
{
$file_type = strrchr( $file, "." );
$is_image = eregi( "jpg|gif",$file_type );
if ( $file != '.' && $file != '..' && $is_image ) {
print("<img src=\"" . $path . "/" . $file . "\" alt=\"Image\" class=\"listimg\" /><br />\n<input type=\"text\" class=\"images-code\" value=\"&lt;a href=&quot;http://www.ishmoo.com&quot; alt=&quot;Ishmoo - Myspace Resource&quot; /&gt;&lt;img src=&quot;http://www.ishmoo.com/Images/Family_Guy/images/" . $file . "&quot /&gt;&lt;/a&gt;\"\n/>");
}
}
closedir ($imgDir);
?>[/code]
So I have this lovely code, derived from one of the examples on this site, being used for my new MySpace site. However, I'd rather not display all of the 500 someodd images that will be in one directory at a time, more like 5 per page. How would I go about doing something like this? I've done it with PHP/MySQL before, but never really had a grasp on it, and have never tried it with a list of files, either.

Thanks in advance!
Link to comment
https://forums.phpfreaks.com/topic/27523-pagination-on-images-from-directory/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.