我正在进行ajax滚动分页。控制器如下所示
value={this.state.encrypted}
$ count变量包含5个数据,我想为第一页发送3,为第二页发送剩余。怎么做。
答案 0 :(得分:1)
试试这个......
<强>型号:强>
function getcourses($tutorId, $limit = null) {
$this->db->select('*');
$this->db->from('courses');
$this->db->where("tutorId", $tutorId);
//$this->db->order_by("name", "asc");
if($limit!=''){
$this->db->limit($limit);
}
$query = $this->db->get();
$courses = array();
foreach ($query->result() as $row)
array_push($courses, $row);
return $courses;
}
<强>控制器:强>
public function index(){
$tutorId = $this->session->userdata('cp_userid');
$limit = 3;
$categorycourses = $this->Usermodel->getcourses($tutorId, $limit);
//$categorycourses=$this->Usermodel->getcourses($tutorId);
$count = $categorycourses->num_rows();
$data['details'] = $categorycourses;
$this->load->view("user/pagination_view", $data, true);
}