php - Adding dots between numbers of pagination -


i have written code pagination in php , ajax table. in each page show 8 rows of table. works fine until here.

what need make pagination looks series of numbers , dots between them (1 2 3 .... 27 28 29).

i have 2 files pagination:

conf.php

<head>     <meta http-equiv="content-type" content="text/html; charset=utf-8" />     <link rel="stylesheet" id="font-awesome-style-css"         href="http://phpflow.com/code/css/bootstrap3.min.css" type="text/css"          media="all">     <script type="text/javascript" charset="utf8"          src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.8.2.min.js">     </script> </head>  <body>      <div>         <p> table <br/> </p>         <div id="target" >loading ...</div>          <?php             include('dbconnect.php');              $limit = 8;             $sql = "select * places";               $rs_result = mysqli_query($connect,$sql);                $c = mysqli_num_rows($rs_result); //count number of rows             $total_num_pages = ceil($c / $limit);          ?>          <div align="center">             <ul class='pagination text-center' id="pagination">             <?php              if(!empty($total_num_pages)):for($j=1; $j<=$total_num_pages; $j++):                 if($j == 1):?>                     <li class='active' id="<?php echo $j;?>">                         <a href='paginate.php?page=<?php echo $j;?> '><?php echo $j;?></a>                     </li>                  <?php else:?>                     <li id="<?php echo $j;?>">                         <a href='paginate.php?page=<?php echo $j;?>'><?php echo $j;?></a>                     </li>                 <?php endif;?>                       <?php endfor;endif;?>             </ul>           </div>     </div>     <script>         jquery(document).ready(function() {         jquery("#target").load("paginate.php?page=1");             jquery("#pagination li").live('click',function(e){             e.preventdefault();                 jquery("#target").html('loading...');                 jquery("#pagination li").removeclass('active');                 jquery(this).addclass('active');                 var pagenum = this.id;                 jquery("#target").load("paginate.php?page=" + pagenum);             });             });     </script> </body> 

the second paginate.php:

<?php     include('dbconnect.php');      $limit = 8;       if (isset($_get["page"])) { $page  = $_get["page"]; } else { $page=1; };       $start_from = ($page-1) * $limit;        $query = "select * places order id asc limit $start_from, $limit";       $result = mysqli_query($connect,$query);       if(!$query)     {         echo mysql_error();     } ?>  <?php      echo '<p style="color:#003566;font-size:15px;">  &nbsp; on page ' .$page. '<br> </p>';     echo '<table border="1" align="center">';      echo '<tr><th>name</th><th>link</th><th>my date</th><th>end date</th><th>place</th></tr>';      while ($row = mysqli_fetch_assoc($result)) {          echo "<tr><td>";         echo $row['name'];          echo "</td><td>";         echo $row['link'];          echo "</td><td>";            echo $row['date'];         echo "</td><td>";         echo $row['end'];          echo "</td><td>";            echo $row['place'];         echo "</td></tr>";        }     echo '</table>'; ?> 

can show me way that?

<?php $numbers = array(1,2,3,4,5,6,7,8,9,10,11,12); $output = ''; $counter = 1; foreach ($numbers $number){     if($counter == 4){         $output .= ' ...';     }elseif($counter < 4 || $counter > (count($numbers) -3)){         $output .= ' ' . $number;     }     $counter++; } 

check link also


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -