Im pulling content from my database and running through it with a foreach loop. Every item I pull has a column with an ID, and a column with PARRENT ID (among other columns). First, im pulling all the rows where my PARRENT ID column equals 0, and output them via my foreach loop, but for every result I get, I want to run a new query to check for rows where PARRENT ID is equal to its ID. For every result I get here, I want to do the same again and again, for as many results it may find (Potentially this could go on forever).
Let me try to visualize this
ID = 1, PARRENT ID = 0
ID = 2, PARRENT ID = 0
ID = 3, PARRENT ID = 0
ID = 4, PARRENT ID = 3
ID = 5, PARRENT ID = 3
ID = 6, PARRENT ID = 5
ID = 7, PARRENT ID = 3
ID = 8, PARRENT ID = 3
ID = 9, PARRENT ID = 0
ID = 10, PARRENT ID = 0
ID = 11, PARRENT ID = 10
ID = 12, PARRENT ID = 11
ID = 13, PARRENT ID = 12
ID = 14, PARRENT ID 13
How do i go about this?