Advertisement
Guest User

Untitled

a guest
Sep 5th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. $db_host = "localhost";
  2. $db_username = "root";
  3. $db_pass = "";
  4. $db_name = "final";
  5.  
  6. $con= mysqli_connect("$db_host","$db_username","$db_pass") or die ("could not connect to mysql");
  7.  
  8. mysqli_select_db($con, "final") or die ("no database");
  9.  
  10. $pagination_sql = "SELECT * FROM `ongoing` WHERE approved='approve'";
  11. $run_pagination = mysqli_query($con, $pagination_sql);
  12.  
  13. $count = mysqli_num_rows($run_pagination);
  14.  
  15. $total_pages = ceil($count/$per_page);
  16.  
  17. echo "<ul class='pagination'>";
  18. echo "<li class='page-item'><a class='page-link' href='ongoing.php?page=".($page-1)."' class='button'>
  19. <span aria-hidden='true'>&laquo;</span>
  20. <span class='sr-only'>Previous</span>
  21. </a></li>";
  22.  
  23. for($i=1;$i<=$total_pages;$i++){
  24.  
  25. echo'<li><a class="page-link" href="ongoing.php?page='.$i.'">'.$i.'</a></li>';
  26.  
  27. };
  28.  
  29. echo "<li class='page-item'><a class='page-link' href='ongoing.php?page=".($page+1)."' class='button'>
  30. <span aria-hidden='true'>&raquo;</span>
  31. <span class='sr-only'>Next</span>
  32. </a></li>";
  33. echo "</ul>";
  34. ?>
  35.  
  36. $per_page = 10;
  37. if(isset($_GET['page'])){
  38. $page = $_GET['page'];
  39. }else{
  40. $page= 1;
  41. }
  42. $start_from = ($page-1) * $per_page;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement