• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multiple Pagination in a Multi Tabbed Page Codeigniter

#1
So I tried to create a pagination to my "User Accounts" Page, and these accounts were divide to three (Homeowner, Admin, Deactivated). These tabs are just placed in one page. The information to be shown are retrieved from the database. I've already created pagination for each of the tab, however, each link points me out to the homeowner page, which is the index. I can't seem to figure this one out. For example, If I go to the Page 2 of my Administrator tab, it redirects me to Page 2 of Homeowner tab.
Here is a video that shows my problem: https://www.youtube.com/watch?v=rjgi0vQ3azA&feature=youtu.be

Controller:

Code:
function index()
   {
       $this->load->model('model_accounts');

       $query = $this->db->select('*')->from('accounts')-> where('role', 0)-> where('isActive', 1)->get();
       $config['base_url'] = site_url('admin_accounts/index');
       $config['total_rows'] = $query->num_rows();
       $config['per_page'] =  10;
       $config['full_tag_open'] = "<ul class='pagination'>";
       $config['full_tag_close'] ="</ul>";
       $config['num_tag_open'] = '<li>';
       $config['num_tag_close'] = '</li>';
       $config['cur_tag_open'] = "<li class='disabled'><li class='active'><a>";
       $config['cur_tag_close'] = "<span class='sr-only'></span></a></li>";
       $config['next_tag_open'] = "<li>";
       $config['next_tagl_close'] = "</li>";
       $config['prev_tag_open'] = "<li>";
       $config['prev_tagl_close'] = "</li>";
       $config['first_tag_open'] = "<li>";
       $config['first_tagl_close'] = "</li>";
       $config['last_tag_open'] = "<li>";
       $config['last_tagl_close'] = "</li>";
       $this->pagination->initialize($config);  
       $data['paginglinks'] = $this->pagination->create_links();


       $query2 = $this->db->select('*')->from('accounts')-> where('role', 1)-> where('isActive', 1)->get();
       $config2['base_url'] = site_url('admin_accounts/index');
       $config2['total_rows'] = $query2->num_rows();
       $config2['per_page'] =  10;
       $config2['full_tag_open'] = "<ul class='pagination'>";
       $config2['full_tag_close'] ="</ul>";
       $config2['num_tag_open'] = '<li>';
       $config2['num_tag_close'] = '</li>';
       $config2['cur_tag_open'] = "<li class='disabled'><li class='active'><a>";
       $config2['cur_tag_close'] = "<span class='sr-only'></span></a></li>";
       $config2['next_tag_open'] = "<li>";
       $config2['next_tagl_close'] = "</li>";
       $config2['prev_tag_open'] = "<li>";
       $config2['prev_tagl_close'] = "</li>";
       $config2['first_tag_open'] = "<li>";
       $config2['first_tagl_close'] = "</li>";
       $config2['last_tag_open'] = "<li>";
       $config2['last_tagl_close'] = "</li>";
       $this->pagination->initialize($config2);  
       $data['paginglinks2'] = $this->pagination->create_links();

       $query3 = $this->db->select('*')->from('accounts')-> where('isActive', 0)->get();
       $config3['base_url'] = site_url('admin_accounts/index');
       $config3['total_rows'] = $query3->num_rows();
       $config3['per_page'] =  10;
       $config3['full_tag_open'] = "<ul class='pagination'>";
       $config3['full_tag_close'] ="</ul>";
       $config3['num_tag_open'] = '<li>';
       $config3['num_tag_close'] = '</li>';
       $config3['cur_tag_open'] = "<li class='disabled'><li class='active'><a>";
       $config3['cur_tag_close'] = "<span class='sr-only'></span></a></li>";
       $config3['next_tag_open'] = "<li>";
       $config3['next_tagl_close'] = "</li>";
       $config3['prev_tag_open'] = "<li>";
       $config3['prev_tagl_close'] = "</li>";
       $config3['first_tag_open'] = "<li>";
       $config3['first_tagl_close'] = "</li>";
       $config3['last_tag_open'] = "<li>";
       $config3['last_tagl_close'] = "</li>";
       $this->pagination->initialize($config3);  
       $data['paginglinks3'] = $this->pagination->create_links();

       $data['users'] = $this->model_accounts->get_users($config['per_page'], $this->uri->segment(3));
       $data['admin'] = $this->model_accounts->get_admin($config['per_page'], $this->uri->segment(3));
       $data['deact'] = $this->model_accounts->get_deact($config['per_page'], $this->uri->segment(3));
       $data['main_content'] = 'view_adminaccounts';
       $this->load->view('includes/admin_accounts_template', $data);
   }

Model:

Code:
function get_users($limit, $offset)
{
  $this->db->limit($limit,$offset);
  $users = $this->db->select('*')->from('accounts')-> where('role', 0)-> where('isActive', 1)->get();
  if($users->num_rows() > 1)
   {
       return $users->result();  
   }
   else
   {
       return $users->result();
   }    
}

function get_admin($limit, $offset)
{
  $this->db->limit($limit,$offset);
  $admin = $this->db->select('*')->from('accounts')-> where('role', 1)-> where('isActive', 1)->get();
  if($admin->num_rows() > 1)
   {
       return $admin->result();  
   }
   else
   {
       return $admin->result();
   }        
}

function get_deact($limit, $offset)
{
  $this->db->limit($limit,$offset);
  $deact = $this->db->select('*')->from('accounts')-> where('isActive', 0)->get();
  if($deact->num_rows() > 1)
  {
       return $deact->result();  
  }
  else
  {
       return $deact->result();
  }          
} function get_users($limit, $offset)
{
  $this->db->limit($limit,$offset);
  $users = $this->db->select('*')->from('accounts')-> where('role', 0)-> where('isActive', 1)->get();
  if($users->num_rows() > 1)
   {
       return $users->result();  
   }
   else
   {
       return $users->result();
   }    
}

function get_admin($limit, $offset)
{
  $this->db->limit($limit,$offset);
  $admin = $this->db->select('*')->from('accounts')-> where('role', 1)-> where('isActive', 1)->get();
  if($admin->num_rows() > 1)
   {
       return $admin->result();  
   }
   else
   {
       return $admin->result();
   }        
}

function get_deact($limit, $offset)
{
  $this->db->limit($limit,$offset);
  $deact = $this->db->select('*')->from('accounts')-> where('isActive', 0)->get();
  if($deact->num_rows() > 1)
  {
       return $deact->result();  
  }
  else
  {
       return $deact->result();
  }          
}

View:

Code:
<div class="portlet-body">

 <div class="tab-content">

   <div class="tab-pane fade in active" id="portlet_tab1">

     <div class="table-responsive">

       <table class="table table-hover" id="tracking-table">

         <tr>
             <th><br>First Name</th>
             <th><br>Last Name</th>
             <th><br>Username</th>
             <th><br>Address</th>
             <th class="not-important"><br>E-mail Address</th>
             <th class="not-important"><br>Contact Number</th>
             <th class="not-important"><br>Action</th>
             <th class="mobile-important"><br>Action</th>
         </tr>

         <?php foreach($users as $row): ?>
         <tr>
             <td><?php echo $row->firstname; ?></td>
             <td><?php echo $row->lastname; ?></td>
             <td><?php echo $row->username; ?></td>
             <td><?php echo $row->address; ?></td>
             <td class="action-button not-important"><?php echo $row->email; ?></td>
             <td class="action-button not-important"><?php echo $row->contactnum; ?></td>
             <td class="action-button not-important">
               <a href="admin-accounts-edit.html"><button type="button" class="btn btn-custom-2">Edit</button></a>
               <button type="button" class="btn btn-custom-3" data-toggle="modal" data-target="#delete-modal"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span>  Delete </button>
               <button type="button" class="btn btn-custom-4" data-toggle="modal" data-target="#deactivate-modal"> Deactivate </button>
             </td>
             <td class="action-button mobile-important">
               <a href="admin-accounts-edit.html"><button type="button" class="btn btn-custom-3">View More</button></a>
             </td>

         <?php endforeach; ?>
         </tr>

       </table>
       <?php echo $paginglinks; ?>
     </div>

   </div>


   <div class="tab-pane fade" id="portlet_tab2">

     <div class="table-responsive">

       <table class="table table-hover" id="tracking-table">

         <tr>
             <th><br>First Name</th>
             <th><br>Last Name</th>
             <th><br>Username</th>
             <th><br>Address</th>
             <th class="not-important"><br>E-mail Address</th>
             <th class="not-important"><br>Contact Number</th>
             <th class="not-important"><br>Action</th>
             <th class="mobile-important"><br>Action</th>
         </tr>

         <?php foreach($admin as $row): ?>
         <tr>
             <td><?php echo $row->firstname; ?></td>
             <td><?php echo $row->lastname; ?></td>
             <td><?php echo $row->username; ?></td>
             <td><?php echo $row->address; ?></td>
             <td class="action-button not-important"><?php echo $row->email; ?></td>
             <td class="action-button not-important"><?php echo $row->contactnum; ?></td>
             <td class="action-button not-important">
               <a href="admin-accounts-edit.html"><button type="button" class="btn btn-custom-2">Edit</button></a>
               <button type="button" class="btn btn-custom-3" data-toggle="modal" data-target="#delete-modal"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span>  Delete </button>
               <button type="button" class="btn btn-custom-4" data-toggle="modal" data-target="#deactivate-modal"> Deactivate </button>
             </td>
             <td class="action-button mobile-important">
               <a href="admin-accounts-edit.html"><button type="button" class="btn btn-custom-3">View More</button></a>
             </td>

           <?php endforeach; ?>
         </tr>

       </table>
       <?php echo $paginglinks2; ?>
     </div>

   </div>


   <div class="tab-pane fade" id="portlet_tab3">

     <div class="table-responsive">

       <table class="table table-hover" id="tracking-table">

         <tr>
             <th><br>First Name</th>
             <th><br>Last Name</th>
             <th><br>Username</th>
             <th><br>Address</th>
             <th class="not-important"><br>E-mail Address</th>
             <th class="not-important"><br>Contact Number</th>
             <th class="not-important"><br>Action</th>
             <th class="mobile-important"><br>Action</th>
         </tr>

         <?php foreach($deact as $row): ?>
         <tr>
             <td><?php echo $row->firstname; ?></td>
             <td><?php echo $row->lastname; ?></td>
             <td><?php echo $row->username; ?></td>
             <td><?php echo $row->address; ?></td>
             <td class="action-button not-important"><?php echo $row->email; ?></td>
             <td class="action-button not-important"><?php echo $row->contactnum; ?></td>
             <td class="action-button not-important">
               <a href="admin-accounts-edit.html"><button type="button" class="btn btn-custom-2">Edit</button></a>
               <button type="button" class="btn btn-custom-3" data-toggle="modal" data-target="#delete-modal"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span>  Delete </button>
               <button type="button" class="btn btn-custom-4" data-toggle="modal" data-target="#deactivate-modal"> Deactivate </button>
             </td>
             <td class="action-button mobile-important">
               <a href="admin-accounts-edit.html"><button type="button" class="btn btn-custom-3">View More</button></a>
             </td>

         <?php endforeach; ?>
         </tr>

       </table>
       <?php echo $paginglinks3; ?>
     </div>

   </div>

 </div>
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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