Welcome Guest, Not a member yet? Register   Sign In
Retrieving users profile and displaying it.
#1

[eluser]puffnstuff[/eluser]
Just started with Codeigniter and I am using Ion Auth for members administration.

I have a table called "users" with a field of "id" and another "profile" with a field called "id".

When the user is logged in I would like to display the users profile with the equivalent id.

I think I am close to figuring this out. This is what I have in my users model...

Code:
function user_profile() {

  $this->db->select('*');
        $this->db->from('users');
        $this->db->join('profile', 'users.id = profile.id','left');
        $query = $this->db->get();
        
         return $query->result();
        
        

  
  
  }

I am not sure if I am way off base and if I am close I am not sure how to go from here to echo out the profile.
#2

[eluser]Pedroshow[/eluser]
Code:
function user_profile($id) {
$this->db->select('*');
$this->db->from('users');
$this->db->join('profile', 'users.id = profile.id','left');
$this->db->where('users.id', $id);
$query = $this->db->get();
        
return $query->result();
}
#3

[eluser]puffnstuff[/eluser]
[quote author="Pedroshow" date="1344782931"]
Code:
function user_profile($id) {
$this->db->select('*');
$this->db->from('users');
$this->db->join('profile', 'users.id = profile.id','left');
$this->db->where('users.id', $id);
$query = $this->db->get();
        
return $query->result();
}
[/quote]

Changed it to that and I am getting...

Code:
Severity: Warning

Message: Missing argument 1 for Profile_model::user_profile(), called in /Applications/MAMP/htdocs/CodeIgniter_2.1.2/application/controllers/user.php on line 34 and defined

Filename: models/profile_model.php

Line Number: 15

Code:
Severity: Notice

Message: Undefined variable: id

Filename: models/profile_model.php

Line Number: 20
#4

[eluser]Pedroshow[/eluser]
you need pass the user id you want to see when you call the model, eg:

Code:
$this->Profile_model->user_profile(1);
#5

[eluser]puffnstuff[/eluser]
[quote author="Pedroshow" date="1344790142"]you need pass the user id you want to see when you call the model, eg:

Code:
$this->Profile_model->user_profile(1);
[/quote]

Great it works thank you so much!




Theme © iAndrew 2016 - Forum software by © MyBB