php - CodeIgniter Pagination only shows fixed numbers (1,2,3) -


i did pagination pass data through ajax view. in case skip $config['uri_segemnt'] . here set total number of rows , per page manually. function creates html tags , pagination tags , append them view. working pagination shows 3 numbers every time. seems pagination not calculate total row count,how can solve this? here function , view.

php controller function

public function getvoucherajax() {         if (!empty($_post)) {             $offset = $_post['limit'];             $selecttedlist = $_post['listid'];         } else {             $offset = 0;         }          $count = $this->gettotalocount($selecttedlist);         $vouchercount = $count[0]['vcount'];         //$limit = perpage          $allvouchers = $this->voucher_model->getallvouchers($this->perpage(), $offset, $selecttedlist);          $config = array();         $config['total_rows'] = 56;         $config['per_page'] = 10;   ////bootstrap config pagination         $config['full_tag_open'] = '<ul class="pagination">';         $config['full_tag_close'] = '</ul>';         $config['first_link'] = false;         $config['last_link'] = false;         $config['first_tag_open'] = '<li>';         $config['first_tag_close'] = '</li>';         $config['prev_link'] = '&laquo';         $config['prev_tag_open'] = '<li class="prev">';         $config['prev_tag_close'] = '</li>';         $config['next_link'] = '&raquo';         $config['next_tag_open'] = '<li>';         $config['next_tag_close'] = '</li>';         $config['last_tag_open'] = '<li>';         $config['last_tag_close'] = '</li>';         $config['cur_tag_open'] = '<li class="active"><a href="#">';         $config['cur_tag_close'] = '</a></li>';         $config['num_tag_open'] = '<li>';         $config['num_tag_close'] = '</li>';         $this->pagination->initialize($config);         echo 'row count -'.' '.$config['total_rows'];         $links = $this->pagination->create_links();  //        print_r($allvouchers);         ?>         <div class="col-sm-12">             <table class="table table-hover">                 <thead>                     <tr>                         <th width="50">id</th>                         <th width="150">created</th>                         <th width="150">valid from</th>                         <th width="150">valid to</th>                         <th width="100">type</th>                         <th width="100">state</th>                     </tr>                   </thead>                 <tbody>                     <?php                     foreach ($allvouchers['allvouchers'] $rows) {                         ?>                         <tr>                             <td><?php echo $rows['id'] ?></td>                             <td><?php echo $rows['created'] ?></td>                             <td><?php echo $rows['validfrom'] ?></td>                             <td><?php echo $rows['validto'] ?></td>                             <td><?php echo $rows['type'] ?></td>                             <td><?php echo $rows['state'] ?></td>                         </tr>                         <?php                     }                     ?>                 </tbody>             </table>              <?php echo $links; ?>         </div>           <?php     } 

view

<script>     $(function () {          loadlist()         loadvoucher()         pagination()          function loadlist() {             $.ajax({                 method: "post",                 url: "<?php echo base_url(); ?>login/loadlistsajax",             }).done(function ($data) {                 $("#list").html($data);             });         }          function loadvoucher() {             $("#list").change(function () {                 var listid = $(this).val();                 $.ajax({                     method: "post",                     url: "<?php echo base_url(); ?>login/getvoucherajax",                     data: {limit: 0,listid: listid}                 }).done(function($data){                     $("#contents").html($data);                 });             });          }           function pagination(){         $(document).on("click",".pagination li a",function(event) {             event.preventdefault(); //            alert('sddsd');             var segment = $(this).attr("data-ci-pagination-page");             if(!segment){                 segment = 0;             }              var list = $("#list").val(); //            alert(list); //             $.ajax({                     method: "post",                     url: "<?php echo base_url(); ?>login/getvoucherajax",                     data: {limit: segment,listid: list}                 }).done(function($data){                     $("#contents").html($data);                 });          });         }       }); </script>    <div class="col-sm-9">     <div class="row">         <div class="col-sm-3">             <select id="list" class="form-control">              </select>         </div>     </div>       <div id="contents" class="row" style="padding-top: 100px;">        </div> 

enter image description here

at top of image, shows query , total row count.


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -