<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>
<channel>
	<title>Comments on: Displaying N-Deep Trees (Remember Your Algorithms Course?)</title>
	<atom:link href="http://www.toosweettobesour.com/2008/08/05/displaying-n-deep-trees-remember-your-algorithms-course/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.toosweettobesour.com/2008/08/05/displaying-n-deep-trees-remember-your-algorithms-course/</link>
	<description>Far Too Sweet To Be Sour</description>
	<pubDate>Wed, 07 Jan 2009 00:19:03 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Daniel Cousineau</title>
		<link>http://www.toosweettobesour.com/2008/08/05/displaying-n-deep-trees-remember-your-algorithms-course/comment-page-1/#comment-142</link>
		<dc:creator>Daniel Cousineau</dc:creator>
		<pubDate>Mon, 11 Aug 2008 17:19:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.toosweettobesour.com/?p=97#comment-142</guid>
		<description>Right, quick code if one is storing the pregenerated level, but if one is working with actual nested arrays, be they database generated or generated from XML or wherever, recursion is the only choice.</description>
		<content:encoded><![CDATA[<p>Right, quick code if one is storing the pregenerated level, but if one is working with actual nested arrays, be they database generated or generated from XML or wherever, recursion is the only choice.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ivan Iordanov</title>
		<link>http://www.toosweettobesour.com/2008/08/05/displaying-n-deep-trees-remember-your-algorithms-course/comment-page-1/#comment-141</link>
		<dc:creator>Ivan Iordanov</dc:creator>
		<pubDate>Mon, 11 Aug 2008 07:59:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.toosweettobesour.com/?p=97#comment-141</guid>
		<description>Talking about algorithms there is better way (imo) to achieve this task.

Let's take a look at this structure:

name, url, ....., level.
level is an integer that represents the level of a node in tree.
here is an example:

Programming Languages, example.com/languages, 0
PHP, example.com/languages/php, 1
Manual, example.com/languages/php/manual, 2
Examples, example.com/languages/php/examples, 2
Java, example.com/languages/java, 1
Python, example.com/languages/python, 1

and simple php function:
define("TAB", "&#160;&#160;&#160;&#160;");
function displayTree($tree) {
    while list($key, $val) = each($tree) {
        echo str_repeat(TAB, $val['level']).'&lt;a href="'.$val['url'].'" rel="nofollow"&gt;'.$val['name'].'&lt;/a&gt;';
    }
}


In this way you have N-deep tree with single loop. Of course your tree array must be sorted first. You can get similar array from database using nested sets.
Here is more info about nested sets:
http://dev.mysql.com/tech-resources/articles/hierarchical-data.html

With this solution adding or editing new rows is heavier compared to standard way but selecting is very quick. For categories is perfect because categories are not changing each day :)</description>
		<content:encoded><![CDATA[<p>Talking about algorithms there is better way (imo) to achieve this task.</p>
<p>Let&#8217;s take a look at this structure:</p>
<p>name, url, &#8230;.., level.<br />
level is an integer that represents the level of a node in tree.<br />
here is an example:</p>
<p>Programming Languages, example.com/languages, 0<br />
PHP, example.com/languages/php, 1<br />
Manual, example.com/languages/php/manual, 2<br />
Examples, example.com/languages/php/examples, 2<br />
Java, example.com/languages/java, 1<br />
Python, example.com/languages/python, 1</p>
<p>and simple php function:<br />
define(&#8221;TAB&#8221;, &#8220;&nbsp;&nbsp;&nbsp;&nbsp;&#8221;);<br />
function displayTree($tree) {<br />
    while list($key, $val) = each($tree) {<br />
        echo str_repeat(TAB, $val['level']).&#8217;<a href="'.$val['url'].'" rel="nofollow">&#8216;.$val['name'].&#8217;</a>&#8216;;<br />
    }<br />
}</p>
<p>In this way you have N-deep tree with single loop. Of course your tree array must be sorted first. You can get similar array from database using nested sets.<br />
Here is more info about nested sets:<br />
<a href="http://dev.mysql.com/tech-resources/articles/hierarchical-data.html" rel="nofollow">http://dev.mysql.com/tech-resources/articles/hierarchical-data.html</a></p>
<p>With this solution adding or editing new rows is heavier compared to standard way but selecting is very quick. For categories is perfect because categories are not changing each day :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Cousineau&#8217;s Blog: Displaying N-Deep Trees (Remember Your Algorithms Course?) &#124; Development Blog With Code Updates : Developercast.com</title>
		<link>http://www.toosweettobesour.com/2008/08/05/displaying-n-deep-trees-remember-your-algorithms-course/comment-page-1/#comment-138</link>
		<dc:creator>Daniel Cousineau&#8217;s Blog: Displaying N-Deep Trees (Remember Your Algorithms Course?) &#124; Development Blog With Code Updates : Developercast.com</dc:creator>
		<pubDate>Thu, 07 Aug 2008 17:25:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.toosweettobesour.com/?p=97#comment-138</guid>
		<description>[...] his Tower of Power blog Daniel Cousineau has written up a look at using a more detailed categorization method than just a parent/child relationship on your data - [...]</description>
		<content:encoded><![CDATA[<p>[...] his Tower of Power blog Daniel Cousineau has written up a look at using a more detailed categorization method than just a parent/child relationship on your data - [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.490 seconds -->
