1

I had met a basic problem that i want to show specific ‘account’ not all account data from database.

Just like the pic Here, If the user’s account is 'chiquitta'

When user need to edit her account setting

It should only show her account information not all of the account information from database.

I had try to solve this problem but it still show all account ~ Did I miss something?

[my controller]

function index($id = false)
 {
  $data['page_title'] = lang('admins');
  $data['admins']  = $this->auth->get_admin_specific($id);
  $this->load->view($this->config->item('admin_folder').'/admins', $data);
 } 

[my model]

function get_admin_specific($id)
 {
  $this->CI->db->select('*');

  if ($id)
  {
  $this->CI->db->where('id', $id);
  }

  $result = $this->CI->db->get('admin');
  $result = $result->result();

  return $result;
 } 

[my view]

<?php foreach ($admins as $admin):?>
<?php echo $admin->account; ?>
<?php endforeach; ?> 
4

1 に答える 1

0

Hi what do you mean with 'It should only show her account information not all of the account information from database.'? Some fields?

Well if you want to take data form a single user you can do it like this

function get_id($where){
    $this->db->where($where);
    return $this->db->get($this->_table)->row();
}

Set your custom array for $where so it search the only row with the id you are looking. Then in your controller:

$data['result'] = $this->your_model->get_id(array('id'=>$id));
$this->load->view('youview', $data);

Then you can access your data within your view with:

$result->field_name;
于 2012-12-27T17:01:32.717 に答える