title: Simplify table pagination ajax php mysql
body: <p>newbie here. I need some help to simplify my pagination table. This is my current pagination.
  <a href="https://i.stack.imgur.com/UP4Qa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UP4Qa.png" alt="enter image description here"></a></p>
  
  <p>But I want to make like this.</p>
  
  <p><a href="https://i.stack.imgur.com/OH2om.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OH2om.jpg" alt="enter image description here"></a></p>
  
  <p>It is possible to make it with minor changes on my code?</p>
  
  <p>Here I attach my pagination code for reference.</p>
  
  <p><strong>posts.php</strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
      http_response_code(404);
      echo "&lt;h1&gt;404 Page Not found!&lt;/h1&gt;";
      exit;
  }
  
  require 'db_connection.php';
  
  if(isset($_POST['page'])) {
      $page_num = filter_var($_POST['page'], FILTER_VALIDATE_INT,[
          'options' =&gt; [
              'default' =&gt; 1,
              'min_range' =&gt; 1
          ]
      ]); 
      
  } else { $page_num = 1; }
  
  $page_limit = 5;
  $page_offset = $page_limit * ($page_num - 1);
  
  function showPosts($conn, $current_page_num, $page_limit, $page_offset){
      $query = mysqli_query($conn,"SELECT * FROM users LIMIT $page_limit OFFSET $page_offset");
      if(mysqli_num_rows($query) &gt; 0) {
          while($row = mysqli_fetch_array($query)) { 
              echo '&lt;li&gt;&lt;b&gt;'.$row['firstname']." / ".$row['lastname'].'&lt;/b&gt;&lt;p&gt;'.$row['email'].'&lt;/p&gt;&lt;/li&gt;';
          }
          $total_posts = mysqli_num_rows(mysqli_query($conn,"SELECT * FROM users"));
          $total_page = ceil($total_posts / $page_limit);
          $next_page = $current_page_num+1; 
          $prev_page = $current_page_num-1; 
          
         echo "&lt;li&gt;";
          if($current_page_num &gt; 1) {
             echo '&lt;a href="'.$prev_page.'" class="page_link"&gt;Prev&lt;/a&gt;';
          }
          for($i = 1; $i &lt;= $total_page; $i++) {
              if($i == $current_page_num){
                  echo '&lt;a href="'.$i.'" class="page_link active_page"&gt;'.$i.'&lt;/a&gt;';
              }else{
                  echo '&lt;a href="'.$i.'" class="page_link"&gt;'.$i.'&lt;/a&gt;';
              }
              
          }
          if($total_page+1 != $next_page) {
             echo '&lt;a href="'.$next_page.'" class="page_link"&gt;Next&lt;/a&gt;';
          }
          echo "&lt;/li&gt;";
      } else { echo "No Data found !"; }
  }
  showPosts($conn, $page_num, $page_limit, $page_offset);
  ?&gt;</code></pre>
  </div>
  </div>
  </p>