CodeIgniter Forums
Pagination Based on multiple loops in one controller function - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Pagination Based on multiple loops in one controller function (/thread-55834.html)



Pagination Based on multiple loops in one controller function - El Forum - 11-12-2012

[eluser]Unknown[/eluser]
Hi to all,

here i am facing a problem regarding paginatioan search with multiple functions
i attach controller buy.php

and here i written some if else conditions,
in that based on condition i am getting the results
with out paginations its working fine,but if i am included pagination functions its going validation false

help is appreciated,thank you



Pagination Based on multiple loops in one controller function - El Forum - 11-12-2012

[eluser]marcogmonteiro[/eluser]
It would be better if you paste the code inside your post and not as an attachement. Easy to look at and answer your question.

cheers,



Pagination Based on multiple loops in one controller function - El Forum - 11-12-2012

[eluser]Unknown[/eluser]
Code:
if($make != null && $model == null && $FromnewPrice == null && $TonewPrice == null && $states == null && $cities == null && $year == null)
  {
      if($make == 786)
   {
   //$data['newcar'] = $this->Buy_Model->search_newcarALL();
         $this->load->library('pagination');
   $config['base_url'] = base_url().'index.php?buy/newcar/maketype=';
   $config['total_rows'] = count($this->Home_Model->getnewall());//get the number of records
   $config['per_page'] = 5 ;
   $config['full_tag_open'] = '<p>';
   $config['full_tag_close'] = '</p>';
   $config['uri_segment']= 3;
   $config['num_links'] = 20;
   $this->pagination->initialize($config);
      $data['newcar'] = $this->Home_Model->getnewall_det($config['per_page'],$this->uri->segment($config['uri_segment']));
   $data['pagination'] = $this->pagination->create_links();
   }
   else if($make != 786)
   {
   $data['newcar'] = $this->Buy_Model->search_newcarbymake($make);
   }
  }//only year selection
  elseif($make == null && $model == null && $FromnewPrice == null && $TonewPrice == null && $states == null && $cities == null && $year != null)
  {
       if($year == 200014)
    {
    $data['newcar'] = $this->Buy_Model->search_newcarALL();
    }
    else
    {
    $data['newcar'] = $this->Buy_Model->search_newcarbyyear($year);
    }
  
  }//only price selection