Welcome Guest, Not a member yet? Register   Sign In
[solved] Pagination 404 on other pages
#1
Rainbow 
(This post was last modified: 11-02-2015, 07:57 AM by artigianidelweb.)

Hello everybody!   Smile 


I have a question for you Big Grin 


I have created that controller class for my blog:




PHP Code:
<?php

Class Blog extends CI_Controller {
    
    

    public function 
__construct(){
        
parent::__construct(); 
            
        
$this->load->model('Blog_m');
        
$this->load->library("pagination");

    }
    

    
    public function 
index()
    {




                
$config = array();
                
$config["base_url"] = base_url() . 'index.php/blog';
                
$config["total_rows"] = $this->Blog_m->record_count();
                
$config["per_page"] = 2;
                
$config["uri_segment"] = 3;
                
$config['use_page_numbers'] = TRUE;
            
                
$this->pagination->initialize($config);
                
                
//$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
                
$page $this->uri->segment(3);
                
$data["rows"] = $this->Blog_m->getPosts($config["per_page"], $page);
                
$data["links"] = $this->pagination->create_links();
                        
            
                
$this->load->view('blog'$data);
                    


    }
    
    
    
    
    
    
    
        
    
    



My model:


PHP Code:
class Blog_m extends CI_Model {
        
    
    public function 
getPosts($limit$start) {
        
        
    
        
$this->db->limit($limit$start);
        
$this->db->select('blog_title,blog_description,blog_id'); 
        
$this->db->from('blog');
        
        
$q $this->db->get();        
        
        if (
$q->num_rows() > ) {
            
            foreach (
$q->result() as $row) {
                
$data[] = $row
            }
            return 
$data;
        }
        
        return 
false;
    }

[...] 

My view:


PHP Code:
            <?php foreach($rows as $r) : ?>    
            <h3><?php echo $r->blog_title?></h3>    
            <p><a href="blog/view/<?php echo $r->blog_id?>" > <?php echo $r->blog_description?>    </a>
            </p>        
        <?php endforeach; ?>
    
    
<p><?php echo $links?></p> 







So, the result view it'OK,
i have on  http://localhost/codeigniter1/index.php/blog
a page with 2 post and at the bottom the paginator with CORRECT LINKS,
es:

2 ----  links to --> http://localhost/codeigniter1/index.php/blog/2
3 ----  links to --> http://localhost/codeigniter1/index.php/blog/3


but if i click on it, on the other pages,
it returns 404 Page Not Found




What I missed ?

Thank you so much!
Big Grin
Reply


Messages In This Thread
[solved] Pagination 404 on other pages - by artigianidelweb - 11-02-2015, 01:40 AM
RE: Pagination 404 on other pages - by Martin7483 - 11-02-2015, 01:53 AM
RE: Pagination 404 on other pages - by Martin7483 - 11-02-2015, 06:03 AM



Theme © iAndrew 2016 - Forum software by © MyBB