Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Need to be able to add paging to this directory script

Avatar of Neil Thompson
Neil ThompsonFlag for United Kingdom of Great Britain and Northern Ireland asked on
4 Comments1 Solution237 ViewsLast Modified:
I have the following code that pulls all the images from a folder and shows them on screen (reducing them via a thumbnailer etc). How can I get this to be pageable. EG show 5 images per page with a  page 1, page 2, page 3 etc linking to the next images?

Many thanks

 // loop through images folder and obtain all details of allowed files
 $imgFolder = 'thumbs/';

 // write details to screen
 if ($pics[0]!="") {
  foreach ($pics as $p) {
   echo '<tr><td class="photoarea">';
   echo '<a href="'.$imgFolder.$p.'" class="clickme"> <img class="photos" src="thumbnail.php?gd=2&amp;src='.$imgFolder.$p.'&amp;maxw=100 "/>';
   echo '<br><span>Enlarge</span></a>';
   echo '</td><td class="phototext">';

   $thisImg = $imgFolder.str_replace('.jpg','.txt',$p);
   if (file_exists($thisImg)) {
    $fh = fopen($thisImg, 'r');
    $theData = fread($fh, filesize($thisImg));
    echo $theData;
   } else {
    echo $p;

   echo '</td></tr>';

 // -------------------------------------------------------------------------------------
 // functions
 // -------------------------------------------------------------------------------------
 function directory($dir,$filters) {
  if ($filters == "all"){while(($file = readdir($handle))!==false){$files[] = $file;}}
  if ($filters != "all") {
   while (($file = readdir($handle))!==false) {
    for ($f=0;$f<sizeof($filters);$f++):
     if ($system[1] == $filters[$f]){$files[] = $file;}
  sort($files);  // sort by a-z
  return $files;

Avatar of netmunky
netmunkyFlag of United States of America image

Our community of experts have been thoroughly vetted for their expertise and industry experience.

This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answers