多标签页面中的多个分页Codeigniter

时间:2016-12-21 18:16:07

标签: javascript php ajax codeigniter pagination

所以我尝试为我的用户帐户"创建一个分页。页面,这些帐户分为三个(房主,管理员,停用)。这些选项卡只放在一个页面中。从数据库中检索要显示的信息。我已经为每个标签创建了分页,但是,每个链接都指向了房主页面,这是索引。我似乎无法想出这个。例如,如果我转到“管理员”选项卡的第2页,它会将我重定向到“房主”选项卡的第2页。

以下视频展示了我的问题:https://www.youtube.com/watch?v=rjgi0vQ3azA&feature=youtu.be

控制器:

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);
    }

型号:

 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();
   }           
}

查看:

<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>

0 个答案:

没有答案