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

[eluser]penta997[/eluser]
Helo. I'm trying to make a items pagination. I have 3 function, first displaying category, 2nd displaying sucategory. 3rd displaying items is cold get_books_by_subcategory. 3rd function get a segment->url(3) argumnet, i want to make a pagination in the same function. but i cant do it.


This is functions code in controller:
Code:
function get_category()
        {
          
            $query = $this->Kategorie_model->get_category();
            $this->response['podkategorie'] = '';
            $this->response['kategorie'] = '';
            $podkategorie = '';
            
            


            if($query->num_rows() > 0)
            {
                foreach($query->result() as $item)
                {
                    $podkategorie = $this->get_sub_category($item->CAT_ID);
                    
                    $this->response['kategorie'] .=  $this->load->view('Ksiegarnia/left', array('kategorie' =>$item, 'podkategorie'=>$podkategorie), true);
                }
            }

            $data = $this->response['kategorie'];
            return $data;

        }





         function get_sub_category($id)
        {

            
               $this->response['wynik'] = '';

          
               $query = $this->Kategorie_model->get_sub_category($id);
              
               if($query->num_rows() > 0)
               {


                    foreach($query->result() as $row)
                    {

                       $link = site_url('ksiegarnia/get_books_by_subcategory/'.$row->SUBC_ID);
                        $this->response['wynik'] .= '<div class="subcat_name"><a href = "'.$link.'">'.$row->SUBC_Name.'</a></div>';

                    }
               }
               else
               {
                    $this->response['wynik'] = '<H1>BRAK DANYCH </H1>';
               }

          
                return $this->response['wynik'];
        }



        function get_books_by_subcategory()
        {
            $widok['center'] = '';
             $widok['left'] = $this->get_category();
             $widok['right'] = $this->load->view('Ksiegarnia/right', '', true);
              $id = $this->uri->segment(3);
            if(isset($id) and is_numeric($id))
            {
                 $query = $this->Kategorie_model->get_books_by_subcategory($id, $this->uri->segment(4));


                 if($query->num_rows() > 0)
                 {
                        
                    foreach($query->result() as $item)
                    {

                      
                        $widok['center'] .=  $this->load->view('Ksiegarnia/get_books', array('data' =>$item), true);

                    }
                }
                else
                {
                    $widok['center'] = $this->load->view('Ksiegarnia/get_books', array('tytul' =>'<h1>brak danych</h1>'), true);;
                }

                $widok['center'] .= $this->pagination->create_links();
                 $this->load->view('Ksiegarnia/index', $widok);

            }

          

        }

And this is my model:
Code:
function get_books_by_subcategory($id, $offset=0)
        {

                      $config['base_url'] = 'http://lukaszbielecki.cba.pl/ksiegarnia/CI/index.php/ksiegarnia/get_books_by_subcategory/'.$id.'/'.$offset;
                      $config['per_page'] = 7;
                      $this->db->where('SUB_CATEGORY_SUBC_ID', $id);


                      $config['total_rows'] = $this->db->get('books')->num_rows();
                      $config['num_links'] = 20;

                       $this->pagination->initialize($config);
             return   $this->db->get('books',$config['per_page'],$offset);
              //$wynik = $this->db->query("Select * from books where SUB_CATEGORY_SUBC_ID = '".$id."'");
              //return $wynik;
        }

The arguments in url is changing, but dispalyin only a items from first subcategory.
Help, please.


Messages In This Thread
Pagination problem - by El Forum - 01-18-2011, 09:51 AM
Pagination problem - by El Forum - 01-18-2011, 12:14 PM
Pagination problem - by El Forum - 01-18-2011, 12:18 PM
Pagination problem - by El Forum - 01-18-2011, 12:50 PM
Pagination problem - by El Forum - 01-18-2011, 01:06 PM
Pagination problem - by El Forum - 01-18-2011, 06:43 PM
Pagination problem - by El Forum - 01-19-2011, 04:20 AM
Pagination problem - by El Forum - 01-19-2011, 04:55 AM
Pagination problem - by El Forum - 01-19-2011, 05:39 AM



Theme © iAndrew 2016 - Forum software by © MyBB