Welcome Guest, Not a member yet? Register   Sign In
Profile
#1

[eluser]Unknown[/eluser]
Hi, i am trying to make profile page, it works buƄ it looks so difficult. So I would like to ask you if it`s right or you have some better ideas :}

Controller:
Code:
function profile() {
  if (!$this->tank_auth->is_logged_in()) {
   redirect('/auth/login/');
  }
  else {
   $user_id = $this->user_id;
   $q = $this->user_model->getUser_data($user_id);
    $data['user_profile'] = $q;
  
   $this->load->view('user/profile_view', $data);
  }
}
Model
Code:
function getUser_data($user_id) {
  $q = $this->db->where('user_id', $user_id)
          ->get('user_profiles');
    

  return $q->result();
  
}
View
Code:
<?php
foreach ($user_profile as $row ) {
    $id = $row->id;
    $user_id = $row->user_id;
    $role = $row->role;
    $invoice_name = $row->invoice_name;
    $invoice_street = $row->invoice_street;
    $invoice_city = $row->invoice_city;
    $invoice_psc = $row->invoice_psc;
    $invoice_number = $row->invoice_number;
}

echo $id;
echo $user_id;
echo $role;
echo $invoice_name;
echo $invoice_street;
echo $invoice_city;
echo $invoice_psc;
echo $invoice_number;
?>




Theme © iAndrew 2016 - Forum software by © MyBB