0
嗨创建t检讨PHP我想在第n层 创建我t检讨有这个疑问在第n层
<ul style="list-style:none;" id="MainMenu">
<?php
$selectfolders=mysql_query("select * from tbl_folders where user_id=1");
while($foldername=mysql_fetch_array($selectfolders))
{?>
<li style="padding:5px;" >
<?php echo $foldername['title'];?>
<?php
$selecttasks=mysql_query("select * from tbl_tasks where project_id=$foldername[f_id] and parent_id=0");
$numtask=mysql_num_rows($selecttasks);
if($numtask>=1)
{
?>
<ul id="TaskList">
<?php
while($tasks=mysql_fetch_array($selecttasks)){
if($tasks['parent_id']==0)
{?>
<li><?php echo $tasks['title'];?></li>
<?php }
else
{
?>
<li><?php echo $tasks['title'];?>
////////////////////Here will be again new query for subtask and for next step again need to more queries///////////
<?php $selectsubtasks=mysql_query("select * from tbl_tasks where parent_id=$tasks[t_id]");?>
<ul id="SubTaskList">
<?php while($subtask=mysql_fetch_array($selectsubtasks))
{?>
<li><?php echo $subtask['title'];?></li>
<?php }?>
</ul>
</li>
<?php }
}?>
</ul>
<?php }?>
</li>
<?php }?>
</ul>
此运行至二级。但这样我需要越来越多的SQL查询。 所以请帮助我如何在简单的一个或两个SQL查询中创建第n级treview。 会有任何简单的功能,如果可以创建然后请帮助谢谢。
无法编辑添加第二个链接,所以我把它张贴在这里:[this](http://php.net/manual/en/class.recursivetreeiterator.php)可能也有帮助。 – Omniarchos 2014-12-08 13:41:53