Recursively determine parent records?
| From: | Murray @ PlanetThoughtful | Date: | Wed, 06 Oct 2004 05:58:01 +0000 |
| Subject: | Recursively determine parent records? | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-36647@lists.php.net to get a copy of this message | ||
Hi All,
I have recordset that contains a hierarchical representation of records
where a record's [parentid] field contains the recid of the record 'above'
the current record.
A representation might look like this:
Recid, parentid, title
1, 0, Top level record
2, 0, Another top level record
3, 1, A record under the top level record
4, 3, Another level
5, 2, A record under the second top level record
If I have currently retrieved the record with recid of 4, I want to work out
the 'chain' of records that lead back to the top level record it has been
created under.
In this instance, that chain would look like:
4, 3, Another level
3, 1, A record under the top level record
1, 0, Top level record
I'm wondering if anyone can help me work out how to achieve this?
Many thanks in advance!
Much warmth,
Murray
<http://www.planetthoughtful.org/> http://www.planetthoughtful.org
Building a thoughtful planet,
One quirky comment at a time.