Welcome Guest, Not a member yet? Register   Sign In
friends and users
#1

-2 down vote favorite



i am making a friend system for a social networking kind of website.i have completed the search part now i am working on adding friends.so when a logged in user visits a other guy's profile he can send him friend request.so on clicking the button i am taking two parameter one is friend's id and other is user's id and passing it to the model.my tables are user_login for users and friends have 1)user_id1 2)friend_id1 and so on.so now i want to pass my data that i have recieved after clicking on the add friend button to the database and for that i have to join the two tables.i.e user_login and pivot table friends.so thaton clicking these id's get saved in that pivot table.just wanted someone to help me with the joining of tables.since it is showing me error. my code for model is


Code:
public function display_followers($user_id,$friend_id)
{

$this->db->select('*');
$this->db->from('user_login');
$this->db->where('id',$user_id);
$this->db->where('id',$friend_id);

$this->db->join('user_login', 'users_login.id = friends.user_id');
$this->db->join('user_login', 'users_login.id = friends.friend_id');


$query=$this->db->get();
if($query->num_rows()>0){
return $query->Result();

}
else{
return false;


}
}
}
my code for controller is
Code:
public function followers(){
   $friend_id=$this->uri->segment(3);


   $user_id = $this->session->userdata['logged_in']['id'];




$this->load->model('Main_Model');
$this->Main_Model->display_followers($user_id,$friend_id);
}
Reply


Messages In This Thread
friends and users - by anmol - 04-12-2017, 11:21 AM
RE: friends and users - by xenomorph1030 - 04-14-2017, 05:05 AM



Theme © iAndrew 2016 - Forum software by © MyBB