recursion question
| From: | Robert J. Cissell | Date: | Wed, 30 Aug 2000 16:25:26 +0000 |
| Subject: | recursion question | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-14428@lists.php.net to get a copy of this message | ||
I'm trying to write my first recursive function but I'm not doing too well. I have a
mysql database with the fields of topic_id, topic_name, and parent_topic_id. If I have a topic_id
with a parent_topic_if of 5, I want the function to get the topic_name and parent_topic_id for 5,
and again and again until it reaches a parent_topic_id of 0, which would be my top level. As it
goes, it would store these values in an array which I can run through later to build a path from the
top to whatever topic_id i started out at. What I can't figure is how to set up the recursive
function to do so. I have no problem with the database stuff, but I need help with the function
stuff. Any ideas or suggestions are greatly appreciated.
Robert Cissell