Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. <?php
  2.  
  3. $dir = "./images/NYC/Gallery/";
  4. $perPage = 18;
  5. if($_GET['currentPage']) {
  6. $currentPage = $_GET['currentPage'];
  7. } else {
  8. $currentPage = 1;
  9. }
  10.  
  11. if (is_dir($dir)) {
  12. if ($dh = opendir($dir)) {
  13. $images = array();
  14.  
  15. while (($file = readdir($dh)) !== false) {
  16. if (!is_dir($dir.$file)) {
  17. $images[] = $file;
  18. }
  19. }
  20.  
  21. closedir($dh);
  22. }
  23. }
  24.  
  25. $numImages = count($images);
  26. $numPages = round($numImages / $perPage + 1);
  27. if($currentPage == 8) {
  28. $images = array_slice($images, ($currentPage-1) * $perPage);
  29. } else {
  30. $images = array_slice($images, ($currentPage-1) * $perPage, $perPage);
  31. }
  32.  
  33. <div class="gallery-container">
  34. <?php
  35. foreach($images as $image) {
  36. echo "<div class='gallery modal-pic'><img src='".$dir.$image."'/></a></div>";
  37. }
  38. ?>
  39. </div>
  40. <div id="paginate">
  41. <nav>
  42. <ul class="pagination">
  43. <li><a href="gallery.php?currentPage=1">1</a></li>
  44. <li><a href="gallery.php?currentPage=2">2</a></li>
  45. <li><a href="gallery.php?currentPage=3">3</a></li>
  46. <li><a href="gallery.php?currentPage=4">4</a></li>
  47. <li><a href="gallery.php?currentPage=5">5</a></li>
  48. <li><a href="gallery.php?currentPage=6">6</a></li>
  49. <li><a href="gallery.php?currentPage=7">7</a></li>
  50. <li><a href="gallery.php?currentPage=8">8</a></li>
  51. </ul>
  52. </nav>
  53. </div>
  54.  
  55. <style>
  56. body {
  57. padding-top: 50px;
  58. }
  59.  
  60. .gallery {
  61. margin: 5px;
  62. border: 1px solid #ccc;
  63. float: left;
  64. width:180px;
  65. height:120px;
  66. }
  67.  
  68. .gallery:hover {
  69. border: 1px solid #777;
  70. }
  71.  
  72. .gallery img {
  73. max-height:100%;
  74. max-width:100%;
  75. margin:0 auto;
  76. }
  77.  
  78. #title {
  79. text-align:center;
  80. margin-bottom:0;
  81. }
  82.  
  83. #paginate {
  84. text-align:center;
  85. }
  86.  
  87. .gallery-container {
  88. margin: 0 auto;
  89. text-align:center;
  90. padding-left:65px;
  91. }
  92.  
  93. .clear {
  94. clear:both;
  95. }
  96.  
  97. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement