Well, the problem here starts where you make two queries instead of one. The second one, using the same variable names, cancels out the first one.
What you should do, and I can't help you directly without knowing more about the 'profiles' table, is look into the JOIN or INNER JOIN sql syntaxes, perhaps.
Your second problem is that you used extract($picture), which I feel is a bit dodgy, but whatever happened you ended up with an array anyway. Remember that $picture is the mysql array, perhaps you'd have more luck with something like this:
echo "<td><a href='".$picture["username"]."/".$picture["picture"]."'><img src='".$picture["username"]."/td_".$picture["picture"]."'></a></td>\n";
Once you've got the joined array working.