pagination links problem

#1
[eluser]Unknown[/eluser]
Seems I always have problems other people don't have, anyway...

I got the pagination working perfectly, however when I click the links to go to a new page the pagination links won't update. When I go from the first page to the 5th page it's still the first link that is selected as current page instead of the 5th link, this has as result that the link to go to the first page is not clickable while the link to the 5th page still is clickable.

for the rest everything is working fine, the records are displayed accordingly to their pages.

my controller:
Code:
/*#######################################################*/
    function tutorial($user = '', $offset = 0)
/*#######################################################*/
    {
        $this->load->model('home_model');
        $this->load->library('pagination');
        
        $data['username'] = $user;
        
        $data['user'] = $this->home_model->getProfileInfo($user);
        
        $config['base_url'] = base_url()."home/tutorial/".$user;
        $config['total_rows'] = $this->home_model->getTutCountByUser($user);
        $config['per_page'] = 2;
        $config['num_links'] = 20;
        
        $this->pagination->initialize($config);
        
        $data['tutorials'] = $this->home_model->getTutByUser($user, $config['per_page'], $offset);//where 10 is the amount of rows to be returned
        
        $data['badges'] = $this->home_model->getUserBadges($user);
        
        $data['cattutcounts'] = $this->home_model->getCatCountByUser($user);

        $data['main_content'] = 'tutorial';
        $this->load->view('template_user', $data);
    }//end of function tutorial

My model
Code:
/*#######################################################*/
    function getTutByUser($user, $limit, $offset)
/*#######################################################*/
    {
        $q = $this->db->query("SELECT tutorials.*, categories.category_name, ci_users.username FROM tutorials
                                INNER JOIN ci_users ON (ci_users.id = tutorials.user_id)
                                INNER JOIN categories ON (tutorials.category_id = categories.category_id)
                                WHERE ci_users.username='".$user."'
                                ORDER BY categories.category_name
                                LIMIT ".$offset.", ".$limit."
                                ");

        if($q->num_rows() > 0):
            foreach($q->result() as $row):
                $data[] = $row;
            endforeach;
            return $data;
        else:
            return false;
        endif;
    }//end of function getTutByUser()


and only a part of the view:

Code:
<table class="tutorial_list" cellspacing="0" cellpadding="0">
            <tr>
                <th>Title</th>
                <th>Url</th>
                <th>Category</th>
                <th>Actions</th>
            </tr>
            
            &lt;?php $i = 0;?&gt;
            
        &lt;?php foreach($tutorials as $tut): ?&gt;
            
            <tr class="&lt;?php if(($i % 2) == 0): echo "even"; else: echo"odd"; endif; ?&gt;">
                <td>&lt;?php echo $tut->title; ?&gt;</td>
                <td><a >url; ?&gt;" target="_blank">&lt;?php echo $tut->url; ?&gt;</a></td>
                <td>&lt;?php echo $tut->category_name; ?&gt;</td>
                <td>
                    <a >tutorial_id; ?&gt;">
                        <img src="&lt;?php echo _TemplatePath_; ?&gt;images/edit.png">title; ?&gt;" title="Edit: &lt;?php echo $tut->title; ?&gt;" />
                    </a>
                    <a >tutorial_id; ?&gt;">
                        <img src="&lt;?php echo _TemplatePath_; ?&gt;images/delete.png">title; ?&gt;" title="Delete: &lt;?php echo $tut->title; ?&gt;" />
                    </a>
                </td>
            </tr>
            
            &lt;?php $i++; ?&gt;
            
        &lt;?php endforeach; ?&gt;
        
        </table>
        
        &lt;?php echo $this->pagination->create_links(); ?&gt;

some of the code in the view displayed above is messed up, but i can't fix it so don't worry if it looks a bit weird and it's the last line that is the most important anyway

#2
[eluser]pickupman[/eluser]
You need to change the uri segment since you have the offset as the 4th parameter
Code:
$config['uri_segment'] = 4;

#3
[eluser]Unknown[/eluser]
thanks Big Grin

#4
[eluser]Corbee[/eluser]
Thanks, I didn't know that was the simple solution too!


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.