pl0x Posted April 13, 2006 Share Posted April 13, 2006 I have this code, but result is empty ... Help me =)<?php $a_tree=array(); $r=mysql_query("select c.id,c1.id as qqq, c.name from catalog c left join catalog c1 on c.parentcatalog=c1.id order by c.name"); for($i=0;$i<mysql_num_rows($r);$i++) { $f=mysql_fetch_assoc($r); if(empty($a_tree[$f['id']])) $a_tree[$f['id']]=array(); $a_tree[$f['id']][]=$f; } function tree_print($a_tree,$k_parent=0) { if(empty($a_tree[$k_parent])) return; echo "<ul>"; for($i=0; $i < count($a_tree[$k_parent]);$i++) { echo "<li>".$a_tree[$k_parent][$i]['name']; tree_print($a_tree,$a_tree[$k_parent][$i]['id']); echo "</li>"; } echo "</ul>"; } tree_print($a_tree);?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.