• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
problem with pagination

#1
i use pagination in codeigniter . and show page number but dosn't show previous and next button


controller code

PHP Code:
$config['base_url'   base_url() . 'track/category/' $title '/page/';
                    
$config['total_rows' $this->custom_model->GetcountDataByCategory('track'$id);
                    
$config['per_page']       30;
                    
$config['uri_segment'] = $this->uri->segment(5);
                    
$page                  = ($this->uri->segment(5)) ? $this->uri->segment(5) : 0;                    
                    
$this->pagination->initialize($config);
                    
$data['pagination'   $this->pagination->create_links();                    
                    
$tracks                $this->track_model->getDataByPaging($id$config['per_page'], $page); 

model code : 
PHP Code:
public function getDataByPaging($id$limit$start){
        
$publishDate strtotime(date('d F Y h:i A'));
 
       $this->db->select('t.id  tid,t.artist_id  tartistid,t.remixer tremixer,t.genre_id  tgenrei,t.category_id tcategory,t.title  ttitle,t.cover  tcover,t.energy,t.label,t.on_sale tonsale,t.featured,t.description,t.publish_date,t.release_date,t.count_download,t.key,t.bpm,t.url,t.lik,artists.id,artists.artist_name,g.id gid,g.name,cat.id catId,cat.title catTitle,');
 
       $this->db->from('track AS t');
 
       $this->db->join('artists','artists.id = t.artist_id');
 
       $this->db->join('genres AS g','g.id = t.genre_id');
 
       $this->db->join('category AS cat',"cat.id = t.category_id");
 
       $where "t.publish_date = 'NULL' OR t.publish_date <= $publishDate AND t.category_id = $id";
 
       $this->db->where($where);
 
       $this->db->order_by('t.release_date','desc');
        
$this->db->limit($limit$start);
 
       $query $this->db->get();
 
       return $query->result();


here
Reply

#2
For one your creating your pagination links before you get you data from the database to display.

Your create links show be last just before your load your view.
What did you Try? What did you Get? What did you Expect?

Joined the CodeIgniter Community in 2009.          ( Skype: insitfx )
Reply

#3
(08-30-2017, 03:23 AM)InsiteFX Wrote: For one your creating your pagination links before you get you data from the database to display.

Your create links show be last just before your load your view.

I did the same, but did not change. Sad
Reply

#4
Try change $config['per_page'] = 3
Reply

#5
It could also be your uri_segment is wrong, use your web browsers development tools
to see what the segments are being returned or echo out your segments and $page.

Most likely you will find that your $page is always returning 0.
What did you Try? What did you Get? What did you Expect?

Joined the CodeIgniter Community in 2009.          ( Skype: insitfx )
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.