>I have a database full of names. each name could be linked to any 
number of
>sub-names, each sub-name could be linked to any number of sub-sub-
names, to
>infinity (unlikely but possible).
>I need to iterate through this nest of names starting with a main 
name; lets
>call the main name Peter. Peter could have John, Tim & Mike working 
for him.
>Tim could have Greg working for him.

Recursion is your friend.

If you're looking to just export a list of names, then try a function 
which does not return anything, but instead:
- is passed the id of the "top"
- selects all direct associations to the "top"
- loops through them (if any):
--- outputting their name
--- invoking the same function with their name as 'top'
- exits.

So, if Andrew has Bob, Cathy, Danielle, and Edward working for him,
and Bob has Frank, Gertrude, and Hector working for him,
and Cathy has Ian and Jill working for her,
and nobody else has any employees:

The first call would be function_name("Peter")
- returns Bob, Cathy, Danielle, Edward
- outputs Bob
- calls function_name("Bob")
--- returns Frank, Gertrude, Hector
--- ouputs Frank
--- calls function_name("Frank")
----- returns nothing
--- outputs Gertrude
--- calls function_name("Gertrude")
----- returns nothing
--- outputs Hector
--- calls function_name("Hector")
----- returns nothing
- outputs Cathy
- calls function_name("Cathy")
--- returns Ian, Jill
--- outputs Ian
--- calls function_name("Ian")
----- returns nothing
--- outputs Jill
--- calls function_name("Jill")
----- returns nothing
- outputs Danielle
- calls function_name ("Danielle")
--- returns nothing
- outputs Edward
- calls function_name ("Edward")
--- returns nothing

Make sense?

Peter Westergaard
[EMAIL PROTECTED]         ###   ICQ#: 10294457
http://www.westergaard.ca/   ###   http://courtly.livejournal.com 
'Alright, you guys start coding.  I'll go find out what the customer 

EASY and FREE access to your email anywhere: http://Mailreader.com/

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to