Ok, it goes like this.
In my MySQL DB, there are 2 tables.
users
and friends
users is basic stuff, and a user_id
friends is as follows
id (key)
user_id (user whose friend this is)
friend_id (user_id of this friend)
Sounds simple, right?
I have a function called get_friends.
It goes like this :
//the degree parameter is nothing (yet!)
function get_friends($user_id, $degree = 1) {
$qry = "SELECT users.user_name,friends.friend_id FROM users INNER JOIN friends ON friends.friend_id = users.user_id WHERE friends.user_id = $user_id";
$this->db_query($qry);
return $this->results;
}
(if the database stuff seems odd, it's because the functionality is built right into the class)
Here's what I need to do - Get Friends (degree = 1), Friends of Friends (degree = 2), or Friends of Friends of Friends (degree = 3)
Any ideas on how to write this kind of function?
I just want to be able to pass it a degree, and have it return an array of user names and user id's
Thanks so much in advance...
PLEASE HELP!!!