I want sort out the data from Categories table like tree structure as given below…
类别表在该表上有带有他的父 ID 的类别......而且每个类别可能有很多孩子......而且每个孩子可能有很多内在孩子......我想根据那个父母得到所有孩子通过动态…… 我无法获取超出某个级别的数据(动态方式)......如何分别获得所有类别和他的孩子的树结构......这可能吗?
![TREE STRUCTURE][1]
From the Table 'categories' as given below...
!['CATEGORIES' TABLE IMAGE][2]
[1]: http://i.stack.imgur.com/1oW5j.png
[2]: http://i.stack.imgur.com/dJ7ht.png
my static code is
$list_pcat_q = mysql_query("select * from categories where parent_id='0'");
while($list_pcat_f = mysql_fetch_array($list_pcat_q)){
$parent=extract($list_pcat_f);
echo"<h3><a href='categories_list.php?cate_id=$cat_id'>".$cat_name."</a></h3>";
$list_scat_q = mysql_query("select * from categories where parent_id=$cat_id");
while($list_scat_f = mysql_fetch_array($list_scat_q)){
extract($list_scat_f);
echo "<h4><a href='categories_list.php?cate_id=$cat_id'>".$cat_name."</a></h4>";
$list_sscat_q = mysql_query("select * from categories where parent_id=$cat_id");
while($list_sscat_f = mysql_fetch_array($list_sscat_q)){
extract($list_sscat_f);
echo "<h5><a href='categories_list.php?cate_id=$cat_id'>".$cat_name."</a></h5>";
$list_ssscat_q = mysql_query("select * from categories where parent_id=$cat_id and final_flag='1'");
while($list_ssscat_f = mysql_fetch_array($list_ssscat_q)){
extract($list_ssscat_f);
echo "<h6><a href='categories_list.php?cate_id=$cat_id'>".$cat_name."</a></h6>";
}
}
}
}