A Code about PHP how to build a genealogy tree
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?
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?
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