-1

I'm Trying to add paginate so once a total of about 12 images display then can click next to display the next 12 images and so on, without reloading the page if possible. Here is the code im using to display the images

<?php
  // open this directory 
  $myDirectory = opendir("upimg");
  $myDir = opendir("thimg");

  // get each entry

  while($entryName = readdir($myDirectory)) {
    $dirArray[] = $entryName;
  }

  // close directory

  closedir($myDirectory);

  //    count elements in array

  $indexCount = count($dirArray);

?>

<?php

  // loop through the array of files and print them all in a list 

  echo "<ul class=\"portfolio clearfix\">" ; 

   for($index=0; $index < $indexCount; $index++) {

      $extension = substr($dirArray[$index], -3);

      if ($extension == 'jpg'){ // list only jpgs

        echo "\n<li class=\"box\"><a href=\"upimg/" . $dirArray[$index] . "\"  class=\"magnifier\" ><img src=\"thimg/" . $dirArray[$index] . "\"   ></a></li>";

      }

    }

  echo "</ul>";
?>  

Any help is greatly appreciated thanks

Albzi
  • 15,431
  • 6
  • 46
  • 63

1 Answers1

1

If you don't want the page to reload you'll need to use AJAX. There are lots of tutorials online. Other than that, there's not much anyone can help you with at present.

paddyfields
  • 1,466
  • 2
  • 15
  • 25