|
Posted by strawberry on 12/01/06 18:18
I know this is probably completely straightforward but how do can adapt
this function so as to merge the results of the recursive queries into
a single, flat array?
function display_children($parent) {
if($parent == 'null'){
$query = "SELECT `id` FROM `task` WHERE ISNULL(`parent`);";}else{
$query = "SELECT `id` FROM `task` WHERE `parent`= '$parent';";}
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)) {
display_children($row['id']);
}
}
So if the results of the 1st query was 1,2,3
and the results of the first recursion was 11,21,31
and the results of second recursion was 118,213,315
I'd end up with array(1,2,3,11,21,31,118,213,315)
As always, any help appreciated.
[Back to original message]
|