dongzhi6382 2016-12-05 05:42
浏览 47
已采纳

分页在codeigniter中不起作用

Listing doctors information using pagination. But listing all doctors information from Database in one page.

Controller

public function doctor_userlist_view($offset = 0)
  {
    $config["base_url"] = base_url() . "User/doctor_userlist_view/";
    $config['total_rows'] = $this->db->count_all_results('tbl_doctor');
    $config['per_page'] = 4;
    $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'] = 'Prev';
    $config['prev_tag_open'] = '<li class="prev">';
    $config['prev_tag_close'] = '</li>';
    $config['next_link'] = 'Next';
    $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);
    $data['docList'] = $this->User_model->get_all_userdoctor($config['per_page'], $offset);
    $data['get_specs'] = $this->specialisation_model->get_specialisation();
    $data['docsideList'] = $this->User_model->get_all_userdocside();
    $data['get_specs'] = $this->specialisation_model->specialisation_get();
    $this->load->view('customer/header', $data);
    $this->load->view('customer/side_view', $data);
    $this->load->view('customer/doctor', $data);
    $this->load->view('customer/footer');
  } 

My view

<div class="list">
<ul>
<?php 
if(isset($docList)):  
         foreach ($docList->result() as $row): 
?>
<li><div class="imgt"><img src="<?php echo base_url("./resources/images/");  if($row->dr_img) echo $row->dr_img; else echo "no-img.jpg"; ?>" height="90px" width="82px"></div><div class="text"><h3><b>Dr. <?php echo  $row->dr_name;?></b><br></h3><p><?php echo $row->spec_specialise; ?><br><?php echo  $row->district;?><br><?php echo  $row->state;?></p></div><div class="text"></div><div class="link"><a href="<?php echo site_url('User/doctor_details_view/'.$row->id); ?>"><i class="ace-icon fa fa-eye sym"></i>View</a></div></li>
 <?php endforeach; 
endif;
 ?>
</ul>
<div class="space">
</div>
</div></div>
<div class="pdt_rightt">
<center>
<?php
   echo $this->pagination->create_links();
?>
</center>
</div>

Pagination is not working properly in all links showing the same data. I use same code for listing hospitals in that pagination is working.

  • 写回答

2条回答 默认 最新

  • drfb52000 2016-12-08 10:54
    关注

    public function get_all_userdoctor($limit, $offset)  
    {  
       
       $this->db->order_by ("id", "desc");  
       $this->db->select('tbl_doctor.*, tbl_specialisation.*');    
       $this->db->join('tbl_specialisation', 'tbl_specialisation.spec_id = tbl_doctor.spec_id');
       $query = $this->db->get('tbl_doctor', $limit, $offset);
       return $query;  
    }

    use this model.Pagination will work properly

    </div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?