"); ?> "; } } getLevelFromDB(0); mysql_close($link); //print one level of the tree, based on parent_id function getLevelFromDB($parent_id){ $sql = "Select item_id, item_nm from Tree where item_parent_id=$parent_id"; $res = mysql_query ($sql); if($res){ while($row=mysql_fetch_array($res)){ print(""); getLevelFromDB($row['item_id']); print(""); } }else{ echo mysql_errno().": ".mysql_error()." at ".__LINE__." line in ".__FILE__." file
"; } } ?>