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