Jump to content

image directory display


BrainSmasher

Recommended Posts

I need a script that displays smaller version of pictures out of a directory on the page and creates more pages where there are more then 16 images in there (so 16 images per page). There need to be an option to delete images by a delete this image link.How can i do this or where can i find examples

Link to comment
Share on other sites

This will store a list of all of the files in a directory in an array structure:

$files = array();$dir = "/tmp";$dh  = opendir($dir);while (false !== ($filename = readdir($dh))) {   if (!is_dir($filename))	 $files[] = $filename;}closedir($dh);

To display 16 per page, you will want to use the querystring to send information about what page you are on. The URL would look something like this:images.php?page=3Some code like this would get that value:

$page = intval($_GET['page']);if ($page < 1)  $page = 1;for ($i = ($page - 1) * 16; $i < ($page * 16) && $i < count($files); $i++){  echo $files[$i];}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...