Im trying to create an employee chain of command in the form of nested divs showing superiority.

I start with a single manager ( id=1 ) and then run 3 of these queries inside each other.

SAMPLE query: SELECT * FROM employees WHERE superior = $superiorID

Obviously this is wrong way to do it. I cant seem to put together a single loop statement that will put all these employees in their respective nested divs in this hierarchy. But i know this is possible.

Hopefully this makes sense and somebody can point me in the right direction. Thanks!!