Welcome Guest, Not a member yet? Register   Sign In
** Help Needed * - Pagination Problem
#1

[eluser]Bainzy[/eluser]
Hi guys,

Being trying to add pagination into my forum script however i am running into some problems.

What i currently have is categories, and when you click on a category it sorts the database again depending on the category selected, this works via the uri->segment(3) method.

here is a example of the code i use, here is my topics model :

Code:
function getTopics($category)
    {
        $data = array();
        
    if ($category)
    {
       $this->db->select('*');
       $this->db->join('category', 'category.CategoryID = topics.CategoryID');
       $this->db->join('users', 'users.Username = topics.CreatedBy');
       $this->db->order_by('topics.TopicID', 'desc');
       $options = array('topics.CategoryID'=>$category, 'topics.Active'=>'1');
       $q = $this->db->get_where('topics', $options);
      
    }
    else
    {
       $this->db->select('*');
       $this->db->join('category', 'category.CategoryID = topics.CategoryID');
       $this->db->join('users', 'users.Username = topics.CreatedBy');
       $options = array('topics.Active'=>'1');
       $this->db->order_by('topics.TopicID', 'desc');
       $q = $this->db->get_where('topics', $options);
    }        
        if($q->num_rows() >0)
        {
            foreach ($q->result_array() as $row)
            {
                $data[] = $row;
            }
        }
        
        $q->free_result();
        return $data;
    } // End of getTopics

And here is my controller code :

Code:
function topics()
    {
        $data['category'] = $this->MCats->getCurrentCat($this->uri->segment(3));
        $data['topics'] = $this->MTopics->getTopics($this->uri->segment(3));
        
        $this->load->view('forums', $data);
    }


Now how would i go about adding pagination into this ? every time i try it does not work or does not work how it should Sad

Any help is appreciated here Smile

Regards
Chris
#2

[eluser]Jan_1[/eluser]
you might show your script with pagination-lines that does not work.
#3

[eluser]Bainzy[/eluser]
I have just added the pagination the same as it says in the codeingiter guideline.
#4

[eluser]umefarooq[/eluser]
if you are using uri segment 3 for category and topic they try to use segment 4 for your pagination will take uri segment by default which is i think 3

give in config segment 4 will work

$config['uri_segment'] = 4;




Theme © iAndrew 2016 - Forum software by © MyBB