Welcome Guest, Not a member yet? Register   Sign In
Pagination - Blank Page
#1

[eluser]Unknown[/eluser]
Hello there.

First off, I'm someone who's really new to CodeIgniter as it's been only around one week. So, naturally, I'm learning still
but I love CodeIgniter already, seeing how much I can do in a really short time.

Anyway. Currently, I've been working on a CI-based project. I had no problem with anything until I got to create a
pagination for the data I retrieve from a database. I tried everything I could with my skills and I searched through
the net, forums and blogs but I couldn't really figure out what I was doing wrong.

So, here the question goes...

Here is my URL structure:

http://localhost/my_site/my_folder/my_class/my_function
(I removed the index.php page using an .htaccess file)

CI is located in the folder "my_folder". And "my_function" has three variables for CRUD actions. (To retrieve the id,
the action etc.)

The problem is when I go to the page: http://localhost/my_site/my_folder/my_cl...function/5, it returns totally a blank
page.

And here are my MVC codes.

Model:
Code:
function get_all_articles($howmany, $offset)
    {
        $this->db->order_by('postTime', 'DESC');
        $query = $this->db->get('articles', $howmany, $offset);
        return $query->result();
    }

Controller:
Code:
public function my_function($var1 = '', $var2 = '', $var3 = '')
    {
    
        if ( ! $var1)
        {

            $config['base_url'] = site_url() . 'my_class/my_function/';
                $config['total_rows'] = $this->db->count_all('articles');
               $config['per_page'] = 5;
                $config['full_tag_open'] = '<div id="pagination">';
                $config['full_tag_close'] = '</div>';
            $this->pagination->initialize($config);
    
            $data['pageTitle']        = 'List of Articles';
            $data['get_articles']    = $this->management_model->get_all_articles($config['per_page'], $this->uri->segment(3));
            $data['paginate']        = $this->pagination->create_links();
            $this->load->view('header', $data);
            $this->load->view('view_file');
            $this->load->view('footer');
        }

        // Rest of the code goes here.

View:
Code:
<table cellspacing="0" cellpadding="5">
            <tr><th>Title</th><th>Time</th><th>Edit</th><th class="rlast">Delete</th></tr>
            &lt;?php foreach ($get_articles as $list): ?&gt;
            <tr>
                <td>&lt;?php echo anchor('link' . $list->id, $list->subject); ?&gt;</td>
                <td>&lt;?php echo date('M j, Y', $list->postTime); ?&gt;</td>
                <td>&lt;?php echo anchor('link' . $list->id, 'Edit'); ?&gt;</td>
                <td>&lt;?php echo anchor('link' . $list->id, 'Delete'); ?&gt;</td>
            </tr>
            &lt;?php endforeach; ?&gt;
        </table>
        &lt;?php echo $paginate; ?&gt;

Thanks in advance for your help.




Theme © iAndrew 2016 - Forum software by © MyBB