Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter Pagination problem
#1

[eluser]InterMedio[/eluser]
Hi all!

I want make pagination for ver 2.1, but I have problem. Below my code:
Model: m_hello.php
Code:
class M_hello extends CI_Model {
    function get_content($num, $offset) {
        $query = $this->db->get('content', $num, $offset);
        return $query->result_array();
    }
}
 
Controller hello.php:
Code:
class Hello extends CI_Controller {
    public function index() {
        $config['base_url'] = base_url().'/hello/'; 
        //$config['total_rows'] = $this->db->count_all('content');
        $config['total_rows'] = 5;
        $config['per_page'] =  1;
        $this->pagination->initialize($config);
        
        $this->load->model('M_hello');
        $data['content'] = $this->M_hello->get_content($config['per_page'], $this->uri->segment(2));
        $this->load->view('v_hello', $data);
    }
And View v_hello.php:
Code:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title><?php echo $title; ?></title>
</head>
<body>
    <?php 
    foreach ($content as $row) {?>
        <div>
            <h3>&lt;?php echo $row['title']; ?&gt;</h3>
            &lt;?php echo $row['text']; ?&gt;
        </div>
    
    &lt;?php 
    }
    echo $this->pagination->create_links();
    ?&gt;
&lt;/body&gt;
&lt;/html&gt;

All helpers(url) and libraries(database, pagination) I have included to autoload.
But when I go to http://ci/hello/2 (click on link in the pagination block), I get message '404 Page Not Found', which generated a CodeIgniter.
I tried to change segment $this->uri->segment(2) to other values, but I received same as error.

Also I inserted to .htaccess next code(for correct url's):

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

Anybody know, how solve this problem?
Thanks!
#2

[eluser]InterMedio[/eluser]
I solved this problem.




Theme © iAndrew 2016 - Forum software by © MyBB