Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CONTROLLER
- <?php
- defined('BASEPATH') or exit('No direct script access allowed');
- class Auth extends CI_Controller
- {
- function update($id){
- $this->data['user'] = $this->Auth_model->get_by_id($id);
- $this->data['get_all_data_access'] = $this->Dataaccess_model->get_all();
- $this->load->view('back/auth/user_edit', $this->data);
- }
- }
- MODEL
- <?php
- defined('BASEPATH') or exit('No direct script access allowed');
- class Auth_model extends CI_Model
- {
- function get_by_id($id){
- $this->db->where($this->id, $id);
- return $this->db->get($this->table)->row();
- }
- }
- <?php
- defined('BASEPATH') or exit('No direct script access allowed');
- class Dataaccess_model extends CI_Model
- {
- function get_all(){
- return $this->db->get($this->table)->result();
- }
- }
- VIEW
- <?php
- $this->db->where('user_id', $user->id_users);
- $dataAccessOld = $this->db->get('users_data_access')->result();
- print_r($dataAccessOld);
- foreach ($get_all_data_access as $alldataAccess) {
- foreach($dataAccessOld as $oldDataAccess){
- if($oldDataAccess->data_access_id == $alldataAccess->id_data_access){
- $checked = 'checked';
- }else{$checked = '';}
- }
- ?>
- <div class="pretty p-icon p-smooth">
- <input type="checkbox" name="data_access_id[]" value="<?php echo $alldataAccess->id_data_access ?>" <?php echo $checked ?>>
- <div class="state p-success">
- <i class="icon fa fa-check"></i>
- <label><?php echo $alldataAccess->data_access_name ?></label>
- </div>
- </div>
- <?php } ?>
Add Comment
Please, Sign In to add comment