Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter Pagination not working correctly?
#1

[eluser]Katsune[/eluser]
Hi,

I'm stucked on pagination, to be exact:
1. All my data is still displayed in one page
2. Whenever I click the second page. it says I have an undefined variable.

Here's my code:

Controller:
Code:
function index()
        {  
         $data['contents'] = $this->content_model->get_content();
            $data['title'] = 'Contents';
            $this->load->view('template/header', $data);  
            $this->load->view('pages/index', $data);
            $this->load->view('template/footer');
            
            $this->load->library('pagination');
            $config['base_url'] = 'http://localhost/AnimeCoffee/index/';
            $config['total_rows'] = 7;
            $config['per_page'] = 2;
            $config['uri_segment'] = 2;
            $this->pagination->initialize($config);
            echo $this->pagination->create_links();
         }

Model:
Code:
public function get_content($ContentID = FALSE)
        {
                if ($ContentID === FALSE)
                {      
                    $this->db->select('ut.Username, ct.Title, ct.ContentID');
                    $this->db->from('username_table AS ut, content_table AS ct');
                    $this->db->where('ut.UserID = ct.UserID');
                    $query = $this->db->get();
                    return $query->result_array();
                }
                $query = $this->db->get_where('content_table', array('ContentID' => $ContentID));
                return $query->row_array();
         }

View:
Code:
<h1>CodeIgniter 2 Tutorial From Header</h1>
    &lt;?php
foreach ($contents as $contents_item):
?&gt;
    <h2>&lt;?php echo $contents_item['Title'] ?&gt;</h2>
    <div id="main">
        &lt;?php echo $contents_item['Username'] ?&gt;
    </div>
    <p><a href="contents/&lt;?php echo $contents_item['ContentID'] ?&gt;">View article</a></p>
&lt;?php endforeach ?&gt;

Maybe someone can shed some light on how to really use the pagination?


Messages In This Thread
CodeIgniter Pagination not working correctly? - by El Forum - 03-30-2014, 05:26 PM
CodeIgniter Pagination not working correctly? - by El Forum - 03-30-2014, 06:06 PM
CodeIgniter Pagination not working correctly? - by El Forum - 03-30-2014, 06:12 PM
CodeIgniter Pagination not working correctly? - by El Forum - 03-31-2014, 04:27 AM
CodeIgniter Pagination not working correctly? - by El Forum - 03-31-2014, 06:12 AM
CodeIgniter Pagination not working correctly? - by El Forum - 03-31-2014, 12:26 PM
CodeIgniter Pagination not working correctly? - by El Forum - 03-31-2014, 02:52 PM
CodeIgniter Pagination not working correctly? - by El Forum - 04-01-2014, 05:58 AM
CodeIgniter Pagination not working correctly? - by El Forum - 04-02-2014, 03:17 AM
CodeIgniter Pagination not working correctly? - by El Forum - 04-02-2014, 03:21 AM
CodeIgniter Pagination not working correctly? - by El Forum - 04-02-2014, 04:42 PM
CodeIgniter Pagination not working correctly? - by El Forum - 04-02-2014, 10:11 PM
CodeIgniter Pagination not working correctly? - by El Forum - 04-03-2014, 01:21 AM
CodeIgniter Pagination not working correctly? - by El Forum - 04-03-2014, 07:09 AM



Theme © iAndrew 2016 - Forum software by © MyBB