View Full Version : How do I use recursion to get a family tree

12-09-2011, 12:06 PM

I am trying to create a family tree, parents / grandparents etc, of a single person...

My database etc is already working but I cannot find any working examples that I can make sense of...

Each of my records has a name, dob and id of each parent....

How can I get X generations from this..

I thought something like this might work..


For each parent GetParents

And so on...

But I have no idea how to put this into code...

Any suggestions to put me on the right line would be greatly appreciated


Old Pedant
12-09-2011, 09:32 PM
Not to ask a sillly question...why is this in the JavaScript forum?

I would think you would be asking this in one of the database forums, depending on what database you are using.

12-09-2011, 09:58 PM
function getParent(current) {
// ...
// ...

Be careful about recursion and variable creation. each variable in the function will be duplicated by the depth of the recursion