A Code about PHP how to build a genealogy tree

Asked By 0 points N/A Posted on -
qa-featured

I am newbie on web development, and I want to create website about families. But in order to do that, I have to build a family tree. Can someone give me a code about PHP how to build a genealogy tree?

Thank you!
SHARE
Answered By 0 points N/A #164500

A Code about PHP how to build a genealogy tree

qa-featured

Hi Hylon,

You can try the following approach:

At first you need to make a single table like the following:

Id

Name

Parent

Parent needs to have the id of the user. For example, a parent with 0 has no parent and a parent with some ID means it is connected to another parent.

If you want to take it further, say you want to show the husband/wife of a person, then you can try the following:

Id

Name

Parent => parent:0 = no parent; parent:-1 = married to someone in the family

Married_to => married_to: 0 = single, no children; married_to: xx (userid) = married to someone

Hope this helps.

Thanks.

Dwalsh

Login/Register to Answer

Related Questions