Jump to content

Recommended Posts

Please help!  I am using a simple gallery script that allows me to create thumbnails based on the jpegs ina specified folder.  The script even includes a variable to change in order to control the amount of columns.  This is great for a few pictures, but what code would I need if there were hundreds and I only wanted only 15-20 thumbnails with a 'next' and 'prev' links to view more?

 

Here is my current code:

 

<?php

 

$images = "photos/"; # Location of small versions

$big    = "big/"; # Location of big versions (assumed to be a subdir of above)

$cols  = 4; # Number of columns to display

 

if ($handle = opendir($images)) {

  while (false !== ($file = readdir($handle))) {

      if ($file != "." && $file != ".." && $file != rtrim($big,"/")) {

          $files[] = $file;

      }

  }

  closedir($handle);

}

 

$colCtr = 0;

 

echo '<table width="10%" cellspacing="3"><tr>';

 

foreach($files as $file)

{

  if($colCtr %$cols == 0)

    echo '</tr><tr><td colspan="2"></td></tr><tr>';

  echo '<td align="center"><a href="' . $images . $file . '"><img src="' . $images . $file . '" / width=70 height=50 border=0></a></td>';

  $colCtr++;

}

 

echo '</table>' . "\r\n";

 

 

?>

Link to comment
https://forums.phpfreaks.com/topic/56082-pagination-with-photo-thumbnails/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.