I don't understand why this is not putting the database values on the page. Can you please tell me what I am doing wrong with this code? I'm a novice at CodeIgniter and this is the first time I'm trying to pass an array from model to controller to view.
Controller Code:
public function showuser(){
$id = $this->uri->segment(3);
$this->load->model('user_model');
$data['user']= $this->user_model->view_user($id);
$this->load->view('include/header');
$this->load->view('user_view',$data);
$this->load->view('include/footer');
}
Model Code:
public function view_user($id){
$this->db->where('userid', $id);
$query = $this->db->get('users');
return $query->result();
}
View Code:
<table width="300" border="0" cellpadding="2">
<tr>
<td width="143">First Name</td>
<td width="143"><?php echo $data['user']->firstname; ?></td>
</tr>
<tr>
<td>Last Name</td>
<td><?php echo $data->lastname; ?></td>
</tr>
<tr>
<td>Company</td>
<td><?php echo $data->company; ?></td>
</tr>
<tr>
<td>Email</td>
<td><?php echo $data->email; ?></td>
</tr>
<tr>
<td>Phone</td>
<td><?php echo $data->phone; ?></td>
</tr>
<tr>
<td><p>Fax</p></td>
<td><?php echo $data->fax; ?></td>
</tr>
<tr>
<td>Address 1</td>
<td><?php echo $data->address1; ?></td>
</tr>
<tr>
<td><p>Address 2</p></td>
<td><?php echo $data->address2; ?></td>
</tr>
<tr>
<td>Address 3</td>
<td><?php echo $data->address3; ?></td>
</tr>
<tr>
<td>City</td>
<td><?php echo $data->city; ?></td>
</tr>
<tr>
<td>State/Region/Province</td>
<td><?php echo $data->state; ?></td>
</tr>
<tr>
<td>Postal Code</td>
<td><?php echo $data->zipcode; ?></td>
</tr>
<tr>
<td>Username</td>
<td><?php echo $data->username; ?></td>
</tr>
<tr>
<td>Account Type</td>
<td><?php echo $data->usertype; ?></td>
</tr>
</table>