0

Here is my index.php code My problem is my pagination has a continuous number of pages.

<?php
    $limit = 10;
    $offset = (isset($_GET["page"]) ? $_GET["page"] - 1 : 0) * $limit;
    $query = "SELECT * FROM employee ORDER BY employee_datecommenced ASC LIMIT                    
    $offset,$limit ";
    $list = getdata_inner_join($query);
?>

<?php
    $total = $dbcon->query("SELECT count(*) FROM employee") or
    die(mysqli_error());     
    $fetch = $total->fetch_assoc();
    for($x = 0; $x < $fetch["count(*)"] / $limit ; $x ++){
        $page = $x + 1;
        if((isset($_GET["page"]) ? $_GET["page"] : 1) == $page)
        $page = "<b>".$page."</b>";  
        echo '<a href="?page='.($x + 1).'"style="padding:2px;">'.$page.'</a>&nbsp;';
    }
?>

Click here to see the output photo

Thanks in advance

EddyTheDove
  • 12,979
  • 2
  • 37
  • 45

2 Answers2

0

You say "My problem is my pagination has a continuous number of pages", but why is that a problem? What do you need to change?

0

in your for loop while printing the anchor tags, check the current page, if suppose the page is ($current), disable ($current-1), and print $current to ($current+5) and '....' and (current+1), if current is $min or $max manage the prev and next

vinay rajan
  • 351
  • 4
  • 9