I am trying to make a family tree creating and editing website. It will be similar to that of http://www.familyecho.com/. I currently have a People table within MYSQL which has a person id as a primary key. A relationships table has the comlums "Person1_id,Person2_id and Relationship(either spouse or parent)". I was curious what kind of recursive function could call back the full family tree of a person and how to then display this diagramaticaly as the family echo website does. I am open to using PHP, Html, javascript or CSS to display.
Asked
Active
Viewed 533 times
0
-
Can you show us any code you've done so far? – TimSPQR Apr 24 '14 at 13:27
-
Possible duplicate of [Mysql recursion](http://stackoverflow.com/questions/4345909/mysql-recursion) – Michael Kunst Apr 24 '14 at 13:30
-
I am currently pulling back everyone in a family tree and placing it in an array using this "$array = array(); $sql = "SELECT * FROM relationships, people WHERE treeid IN (SELECT treeId FROM people WHERE '$_SESSION[Tree]') and (people.Person_id=relationships.Persons1_id OR people.Person_id=relationships.Persons2_id)"); while($row = db_fetch_object($sql)) { $array[] = $row->data; // <<<<----- updated array push } return $array; " Then I was thinking I could traverse the array using something similar to this "http://stackoverflow.com/questions/3304670/family-tree-data-structure" – user3568905 Apr 24 '14 at 14:08
-
I only have a basic understanding of PHP and mysql so i am struggling to understand the best way to approach this. Sorry – user3568905 Apr 24 '14 at 14:09
-
Maybe try the code in the answer of the question you linked and see where it gets you? – Patrick Q Apr 24 '14 at 14:59
-
I have it partially returning the tree using this code. But depending on the node it will only display one side of the tree. It also only displays in a small increment and was wondering if this could be displayed in a diagram? – user3568905 Apr 24 '14 at 15:47
-
Just an update. I am now using the Mysql recursion that Michael Kunst linked to it is retrieving the data from my new single table structure that the top answer outlines however i am still curious how to display this as family echo has – user3568905 Apr 24 '14 at 17:03