我的数据库中有一个"login"answers"profile"表。
login=['id_login、用户名、密码等…']
profile=['id_profile、id_login、全名、地址等']
型号
function my_model(){
$this->db->select('fullname, address, A.name_table, B.name_text');
$this->db->from('profile');
$this->db->join('A','A.id_table=profile.id_table');
$this->db->join('B','B.id_text=profile.id_text');
$query = $this->db->get();
if ($query->num_rows() > 0) {
return $query->row_array();
}
}
控制器
function my_controller(){
$data['view_profil']= $this->model->my_model();
$this->tmp->screen('my_view', $data);
}
我想问什么。如何根据登录id显示配置文件数据?如何在我的视图文件中实现它?谢谢你的帮助。
您需要获取成功登录的配置文件的ID并存储在会话中,然后在查询中使用它(作为where子句)来仅检索该特定配置文件的记录。
$this->db->select('fullname, address, A.name_table, B.name_text');
$this->db->from('profile');
$this->db->where('id', $this->sessoin->userdata('Profile_ID');
然后获取数组并将其显示在视图中!
echo $view_profil['fullname'];