Guest User

Untitled

a guest
Oct 18th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. <?php
  2.  
  3. $limit = 2;
  4.  
  5. if (isset($_GET["page"]))
  6. {
  7. $page = $_GET["page"];
  8. } else
  9. {
  10. $page=1;
  11. };
  12.  
  13. $start_from = ($page-1) * $limit;
  14.  
  15. $sql = "SELECT * FROM album_catagories ORDER BY id DESC LIMIT $start_from, $limit";
  16. $rs_result = mysqli_query($connection, $sql);
  17. ?>
  18.  
  19. <div class="full-gallery">
  20.  
  21. <h3>Gallery</h3>
  22.  
  23. <div class="row">
  24. <div class="content">
  25. <?php
  26.  
  27. while($image = mysqli_fetch_assoc($rs_result))
  28. {
  29. echo '<div class="album_holder">
  30. <img id="myImg" src ="includes/uploads/images/gallery/'.$image['coverimage'].'" class="gallery-image">
  31. <p>'.$image['title'].'</p>
  32. <a id="purple-button" href="viewalbum.php?album='.$image['id'].'">View Album</a>
  33.  
  34.  
  35. </div>';
  36.  
  37. }
  38.  
  39. ?>
  40. </div>
  41.  
  42.  
  43. </div>
  44.  
  45.  
  46.  
  47.  
  48. <div class="pag-menu">
  49.  
  50. <?php
  51.  
  52. $sql = "SELECT COUNT(id) FROM album_catagories";
  53.  
  54. $rs_result = mysqli_query($connection, $sql);
  55.  
  56. $row = mysqli_fetch_row($rs_result);
  57.  
  58. $total_records = $row[0];
  59.  
  60. $total_pages = ceil($total_records / $limit);
  61.  
  62. $pagLink = "<nav><ul class='pagination'>";
  63.  
  64. for ($i=1; $i<=$total_pages; $i++) {
  65. $pagLink .= "<li><a href='gallery.php?page=".$i."'>".$i."</a></li>";
  66. };
  67.  
  68.  
  69. echo $pagLink . "</ul></nav>";
  70. ?>
  71.  
  72.  
  73. </div>
  74.  
  75.  
  76. </div>
  77.  
  78.  
  79.  
  80.  
  81. <?php include('footer.php'); ?>
Add Comment
Please, Sign In to add comment