Welcome Guest, Not a member yet? Register   Sign In
Please, I am getting crazy with the pagination class :(
#1

[eluser]victorche[/eluser]
Here is my model:
Code:
function get_posts($limit, $offset)
    {
        $query = $this->db
            ->select('*')
            ->from('articles')
            ->order_by('id', 'desc')
            ->limit($limit, $offset)
            ->get();

        if ($query->num_rows() > 0)
        {
            foreach ($query->result_array() as $row)
            {
                $entries[] = array(
                    'title' => $row['title'],
                    'body' => character_limiter($row['body'], 800)
                );
            }
            return $entries;
        }
    }

    function count_posts()
    {
        return $this->db->count_all_results('articles');
    }

And this is my controller:

Code:
function index($page = NULL)
    {
        $this->load->model('articles_model');

        $limit = 2;

        if (isset($page) && is_numeric($page))
        {
            $offset = ($page - 1) * $limit;
        }
        else
        {
            $offset = 0;
        }

        $count = $this->articles_model->count_posts();
        $entries = $this->articles_model->get_posts($limit, $offset);

        $config['base_url'] = site_url('articles');
        $config['per_page'] = $limit;
        $config['total_rows'] = $count;

        $this->pagination->initialize($config);
        $pages = $this->pagination->create_links();

        $data = array(
            'articles_heading' => 'Articles Heading',
            'articles_entries' => $entries,
            'articles_pages' => $pages
        );
        }

The links are generated normally, but anyway when I click on page 2, I always have 404 error Sad

Please, help! I've read 200 topics about it and still not success Sad


Messages In This Thread
Please, I am getting crazy with the pagination class :( - by El Forum - 07-17-2010, 03:04 PM
Please, I am getting crazy with the pagination class :( - by El Forum - 07-17-2010, 06:04 PM
Please, I am getting crazy with the pagination class :( - by El Forum - 07-17-2010, 10:53 PM
Please, I am getting crazy with the pagination class :( - by El Forum - 07-18-2010, 02:38 AM
Please, I am getting crazy with the pagination class :( - by El Forum - 07-18-2010, 02:54 AM
Please, I am getting crazy with the pagination class :( - by El Forum - 07-26-2010, 07:31 AM
Please, I am getting crazy with the pagination class :( - by El Forum - 07-26-2010, 08:00 AM
Please, I am getting crazy with the pagination class :( - by El Forum - 07-26-2010, 08:12 AM
Please, I am getting crazy with the pagination class :( - by El Forum - 07-26-2010, 09:10 AM



Theme © iAndrew 2016 - Forum software by © MyBB