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

Posted by rdw on 03/11/07 14:15

Rik wrote:
> 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 ==
> tree_list:
>
> $trail = array(
> 1 => '<drink_id>',
> 2 => '<alcohol_id>',
> 3 => '<beer_id>',
> 4 => '<grolsch_id>'); //Grolsch!
>
> function tree_list($parent=0,$level=1,$trail=array()) {
> // retrieve all children of $parent
> $result = mysql_query("SELECT cname,cid FROM kategorie
> WHERE parent='{$parent}');
> while ($row = mysql_fetch_assoc($result)) {
> echo str_repeat('&nbsp;&nbsp;',$level).$row['cname']."<br/>\n";
> if ($row['cid'] == $id[$level]) tree_list($row['cid'],
> $level+1,$trail);
> }
> }
>
> tree_list(0,1,$trail);
>
> Then again, the previous posted function would result in _less_
> expansion instead of more... (And a notice that $id did not exist, and
> certainly was no array). Seems like someone did not post the exact
> function as actually used?
>
> --Rik Wasmus
> Posted on Usenet, not any forum you might see this in.
> Ask Smart Questions: http://tinyurl.com/anel

THANK you how could i overlook 2 stupid mistakes... typical :)

 

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

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