How would I join these tables together?
===

Alright so I have a few tables that I need help with in joining and displaying. 

`Table 1: users It has the colums: username, password, rights, friends[array]` 

I have the friends array displaying what I kind of what atm like this: 

    `function findFriendsO(){
	include "mysql.php";
	$user = $_SESSION['username'];
	$query = mysql_query("SELECT * FROM users WHERE username LIKE '$user'") or die(mysql_error());
	WHILE($row = mysql_fetch_array($query)){
		$friends = $row['friends'];
		$b = array_unique(array_filter(explode(", ", removeB($friends))));
				echo '
					<div class="tableContainer cssTableSmall">
					<div class="hiscoresBoxTopLeft"></div>
					<div class="hiscoresBoxTopRight"></div>
					<div class="tableInnerContainer">
					<div class="header">
					<span class="columnRank">Rank</span>
					<span class="columnName">
					<span>Name</span>
					</span>
					<span class="columnLevel">
					<span>Level</span>
					</span>
					<span class="columnXp">
					<span>XP</span>
					</span>
					</div>';
		for($j = 0;$j <= count($b);$j++){
			$name = ucwords($b[$j]);
			$rank = findRank($name, "0");
			$rights = findRights($name);
			//$xptype = findType($table)."xp";
			$query2 = mysql_query("SELECT * FROM skillsoverall WHERE playerName LIKE '$name' LIMIT 1") or die(mysql_error());
			$rows = mysql_fetch_array($query2);
			if($rights < 2 && $rank > 0 && ($rows["xp"] > 1184)){    
				//for($i = 0;$i <= count($b);$i++){
				$number = mysql_num_rows($query);
				echo'
					<a name="'.$rank.'"></a>
					<a href="compare.php?user1='.$name.'" target="_self" class="row ">
					
					<span class="columnRank">
					<span>'.$rank.'</span>
					</span>
					<span class="columnName">
					<span>'.BBCode($name).'</span>
					</span>
					<span class="columnLevel">
					<span>'.dots($rows["lvl"]).'</span>
					</span>
					<span class="columnXp">
					<span>'.dots($rows["xp"]).'</span>
					</span>
					</a>
				 ';   
			}
		}
		//var_dump($b);
	}
}`

 But I was told it would be easier if I joined tables together, and had my friends like this: Table: friends Columns: user, friend It would display the user multiple times as many times as the friends they have.

Now my other tables are: 

`skillsoverall and skills Where in skills the columns are:` 
`playerName, and all of their skills` 
`and in skillsoverall the columns are: playerName, lvl, xp` 

Now I want to join the user table with the friends table and display each friend on the skills or skillsoverall table If you are unsure what I mean, this is how my findFriendsO function looks like: http://i49.tinypic.com/35aj5eq.png but I can't order them using the code I have because it's in an array like that. So I made the friends table and am trying to do the same thing, but being able to order it. Sorry if you can't understand what I'm talking about I am a horrible explainer.


  [1]: http://i.stack.imgur.com/T5fb1.png