Have you looked at JOIN-ing tables in the SQL query so you get a more proper result set?
I mean, here's a very basic example:
SELECT a.*, b.*, c.* FROM employees a
INNER JOIN managers b
ON a.manager_id=b.id
INNER JOIN supervisors c
ON b.supervisor_id=c.id
WHERE c.id='5505'
ORDER BY a.id ASC
That would return only the employees under the managers that are under the supervisor with id 5505.
Now, your database structure may need work, but that would be the easiest way to actually do it. Let mySQL do the grunt work (it's what it's there for) and just let PHP run one loop to display the info 😉
SQL can be tricky, so I'd suggest a book. One book that I've found is clear and concise is: "Learning SQL" by Alan Bealieau (published by O'Reily). It goes over plenty of info on SQL and how to use it to your advantage. Plus, it has a very similar query to your situation 🙂