How many levels of recursion are possible / probably with your database?
You can do this a few ways: Programmatically, via PHP code which runs query after query to build the dataset it needs. If you know the max depth is going to be fairly shallow, you can use a fixed query with either a join or nested subqueries. Joins tend to be faster in most databases. Or, you can use PHP to write a giant multi-level join automagically by figuring out the depth first, then building a query to go down just that many levels.
A few questions:
Do you need to know what the path is from parent to child, with all children in between, or just that the child falls under the parent somehow?
How much data are you gonna be trundelling through? This could be quite slow if you have a huge table. You'll definitely need indexes to keep good speed during the query(ies)
The join syntax is something like this:
select * from table t1, table t2, table t3 where t1.id=t2.parentid AND t2.id=t3.parentid and t1.id=12345;
Just keep extending the table out for however many levels you need.