Thanks for the help so far.  I've got much further into it now and 
understand a bit more about trees.  I also found 
http://www.zend.com//code/codex.php?ozid=539&single=1 which proved useful.

I now have my tree populated, then traversed for each node of interest, 
but have a display problem.  My code gives me output like:
      +--James Kibble Sartorelli
   +--Thomas Edmund Sartorelli
      +--Edith Eliza Woods
+--Trevor James Arthur Sartorelli
   +--Edith Emily Warner
      +--Ellen Gurney
Kevin James Sartorelli
      +--Richard Nicholas Salter
   +--Richard Salter
+--Margaret Beulah Salter
      +--Noah Francis Watson
   +--Beulah Watson
      +--Emma Rosina (Rose) Peachey

But what I want is:
      +--James Kibble Sartorelli
   +--Thomas Edmund Sartorelli
   |  +--Edith Eliza Woods
+--Trevor James Arthur Sartorelli
|  +--Edith Emily Warner
|     +--Ellen Gurney
Kevin James Sartorelli
|     +--Richard Nicholas Salter
|  +--Richard Salter
+--Margaret Beulah Salter
   |  +--Noah Francis Watson
   +--Beulah Watson
      +--Emma Rosina (Rose) Peachey

Given $OutputInOrder is my ordered array to be displayed (after inorder 
tree traversal), my code to output the above is (minus all sorts of name 
and date grabbing code):
    $output_count = count($OutputInorder);              // Count how 
many nodes in the output
    for( $j = 0; $j < $output_count; $j++ ){
// Persons name is grabbed from database here using $OutputInorder[$j]
// Persons ahnentafel also grabbed here.  This is node# * 2 for father 
and node# * 2 + 1 for mother
        $indent = ceil(log10($ahnentafel +1)/log10(2)) * 3 - 6;
        for ( $k = 0; $k < $indent; $k++ )      // Indent this person
            echo " ";
        // if not person 1
            echo "+--";
// Display persons name here
    }

How do I work out where to output the '|' bars?  Can this be done in the 
loop above or do I need to go back to the tree?

Cheers
Kevin


--~--~---------~--~----~------------~-------~--~----~
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]
-~----------~----~----~----~------~----~------~--~---

Reply via email to