You are here: Re: rather noob trouble w/ tree expanding « PHP Programming Language « IT news, forums, messages
Re: rather noob trouble w/ tree expanding

Posted by Rik on 03/10/07 20:12

Rik <luiheidsgoeroe@hotmail.com> wrote:
>> Milan Krejci kirjoitti:
>>> $id variable contains an array of branches i want the program to go
>>> through (alcohol's id -> beer id etc)

> Also, what this mysterious $id does, and why it is not fed down the =

> recursion like the rest.

D'OH

But it surely indicates the problem: $id should be in the recursion too.=

Assuming you translated your function's name and actually tree_vypis =3D=
=3D =

tree_list:

$trail =3D array(
1 =3D> '<drink_id>',
2 =3D> '<alcohol_id>',
3 =3D> '<beer_id>',
4 =3D> '<grolsch_id>'); //Grolsch!

function tree_list($parent=3D0,$level=3D1,$trail=3Darray()) {
// retrieve all children of $parent
$result =3D mysql_query("SELECT cname,cid FROM kategorie
WHERE parent=3D'{$parent}');
while ($row =3D mysql_fetch_assoc($result)) {
echo str_repeat('&nbsp;&nbsp;',$level).$row['cname']."<br/>\n";=

if ($row['cid'] =3D=3D $id[$level]) tree_list($row['cid'], =

$level+1,$trail);
}
}

tree_list(0,1,$trail);

Then again, the previous posted function would result in _less_ expansio=
n =

instead of more... (And a notice that $id did not exist, and certainly w=
as =

no array). Seems like someone did not post the exact function as actuall=
y =

used?

-- =

Rik Wasmus
Posted on Usenet, not any forum you might see this in.
Ask Smart Questions: http://tinyurl.com/anel

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация