I want to display both the user table and users_profiles table in 1 table :
I want to link them both so that usrpID = usrID,
Before this process I tried displaying only users table using this code and it works great.
Controller:
$data['query'] = $this->db->query('SELECT * FROM users_profiles');
$this->load->view('users/users_view',$data);
View:
<?php foreach($query->result_array() as $row): ?>
<tr class="even gradeC">
<td><?php echo $row['usrID']</td>
<td><?php echo $row['usrName'];?></td>
</tr>
<? endforeach; ?>
but when I try to join two tables, it returns me an error: this is my code
$this->db->select('users.usrID, users_profiles.usrpID');
$this->db->from('users', 'users_profiles');
$this->db->join('users', 'users.usrID = users_profiles.usrpID');
$result = $this->db->get();
users table has fields like username,password, etc. and every user has his own profile in users_profiles table
users users_profiles
EDIT I tried selecting the fields but when I tried this
<td><?php echo $row['usrID'];?></td>
<td><?php echo $row['usrName'];?></td>
<td><?php echo $row['usrpFirstName'].' '.$row['usrpLastName'];?></td>
<td><?php echo $row['usrpBday'];?></td>
<td><?php echo $row['usrpSex'];?></td>
<td><?php echo $row['usrpAddress'];?></td>
it returns me the first value in users profiles in which it should not
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…