php遞歸實例 通達OA文件櫃樹形結構 遞歸算法

<?
include_once("inc/conn.php");

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>個人文件櫃</title>
<link rel="stylesheet" href="jquerytreeview/jquery.treeview.css" />
	<link rel="stylesheet" href="jquerytreeview/demo/screen.css" />
	<style type="text/css">
		a:link{
	text-decoration:none;
	}
	a:visited{
	text-decoration:none;
	}
	a:hover{
	text-decoration:none;
	}
	a:active{
	text-decoration:none;
	}
    </style>
	<script src="jquerytreeview/lib/jquery.js" type="text/javascript"></script>
	<script src="jquerytreeview/lib/jquery.cookie.js" type="text/javascript"></script>
	<script src="jquerytreeview/jquery.treeview.js" type="text/javascript"></script>
	


<script type="text/javascript">
		$(function() {
			//alert("asasd");
			$("#browser").treeview();
		});
	</script>

</head><body><br/>
    <div align="left" style="margin:10,10,0,10; font-weight:bold; font-size:12px"><a href="#0" >個人文件櫃</a></div>
    <div align="left" style="margin:10,10,10,10; font-size:12px; ">
    <hr color="#0066FF">
  <img src="../../../static/images/org/root.png" />個人文件櫃
  


	
 
	<?
    function list_sort( $PARENT_ID, $SPACE = "1 ",$num)
{
		
	
		$OUTPUT = "";
		if($num==0){
		$query = "SELECT * from file_sort where sort_parent='".$PARENT_ID."' and sort_type='5'  order by sort_no asc";
		}
		else {
			$query = "SELECT * from file_sort where sort_parent='".$PARENT_ID."'  and sort_type='5'  order by sort_no asc";
			}
			//echo $query."<br>";
		$cursor= exequery(TD::conn(),$query);
		while ( $ROW = mysql_fetch_array( $cursor ) )
		{
				++$SORT_COUNT;
				$sort_id = $ROW['SORT_ID'];
				$sort_no = $ROW['SORT_NO'];
				$sort_name = $ROW['SORT_NAME'];
				
				//echo $NEW_USER;
				$query2="select  count(*) from file_sort where sort_parent= ".$sort_id;
				$cursor2= exequery(TD::conn(),$query2);
				$row2=mysql_fetch_row($cursor2);
				if($row2[0]>0)
				$HAVE_CHILD = 1;
				$num++;
					
				
						$OUTPUT .= "<li class=\"closed\">".$SPACE."<img src=\"../../../static/images/org/org.png\" /><a href=\"guanli.php?sort_id={$sort_id}\" target=\"mainFrame\">{$sort_name}</a>";
						
							$a=$SPACE;
						if ( $HAVE_CHILD == 1 )
						{	$SPACE.="1";	
								$OUTPUT .= "<ul id=\"folder_{$sort_id}\">";
								$OUTPUT .= list_sort( $sort_id, $SPACE,$num);
								$OUTPUT .=" </ul>";
						}
						$SPACE=$a;
				$OUTPUT.="</li>";//一定要放到這個地方
		}
		
		return $OUTPUT;
}

?>
	
<ul id="browser" class="filetree">
<? 
$SORT_COUNT = 0;
echo list_sort(0,"1",0);
?>

	</ul>
<hr color="#0066FF">
	</div>
</body></html>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章