Logic of recursive function |
[eluser]Ninjabear[/eluser]
I've been following this article on recursion in php. I just can't get my head around the logic of recursion at the moment. Basically I have a nested tree of projects with infinite levels. So 1 is the root node and then there are others beneath it. Each one has a p_id (primary key) and parent_id to show who its parent is. This is Codeigniter 2.1.0. Code: function recursion($p_id) The get_projects() function just returns a list of projects restricted by certain fields. I don't think the details matter too much except that it ends like this (by all means ask me if it would be helpful): Code: ... So you get either a result or row plus num_rows in an array. get_projects() works throughout the site. The problem is that wherever there is a child element it doesn't get printed. Code: Array Notice here that p_id 2 isn't there but has child elements. |
Messages In This Thread |
Logic of recursive function - by El Forum - 03-30-2012, 01:11 AM
Logic of recursive function - by El Forum - 03-30-2012, 01:36 AM
Logic of recursive function - by El Forum - 03-30-2012, 02:21 AM
Logic of recursive function - by El Forum - 03-30-2012, 02:54 AM
Logic of recursive function - by El Forum - 03-31-2012, 05:26 AM
Logic of recursive function - by El Forum - 03-31-2012, 05:40 AM
Logic of recursive function - by El Forum - 03-31-2012, 07:25 AM
Logic of recursive function - by El Forum - 04-02-2012, 02:42 AM
|