Welcome Guest, Not a member yet? Register   Sign In
Display db data in edit profile page
#1

[eluser]Ignis Avis[/eluser]
I want to display existing data in the fields when i will go to edit page.

Here is my model function.
Code:
public function edit_user($member_id)
{
   $this->db->select('fullname','country','district','address','nominee_name','nominee_relation','mobile_no','password','bank_acc_no','bank_acc_name','bank_name','branch_name');
   $this->db->limit('1');
   return $this->db->get_where('user', array('member_id'=> $member_id))->row();
}

Here is the controller function.
Code:
function edit_profile()
{
  $data['title']= 'Edit Profile';
  $member_id = $this->session->userdata('member_id');
  $this->load->model('user_model','',TRUE);
  $data['row'] = $this->user_model->edit_user($member_id);
        $this->load->view('edit_profile.php', $this->data);
}

and in my view file for a sing field I am using this.
Code:
<input type="text" value="<?php echo $row['full_name'];?>"/>

But I am getting following error.
Code:
Severity: Notice

Message: Undefined variable: row

Filename: views/edit_profile.php
I am new in codeigniter and can't figure out why this is happening.
#2

[eluser]Glazz[/eluser]
Instead of
Code:
$this->load->view('edit_profile.php', $this->data);

Use:
Code:
$this->load->view('edit_profile.php', $data);

#3

[eluser]Ignis Avis[/eluser]
I am using $this->data to load my template data which have been declared earlier.

I am having problem with the variable row in view file. view is not recognizing that. what should i do to solve that issue?
#4

[eluser]Glazz[/eluser]
If you need to have $this->data passed, you need to merge the $data, something like this:

Code:
$this->load->view('edit_profile.php', array_merge($this->data, $data) );




Theme © iAndrew 2016 - Forum software by © MyBB