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 "<item id='" . $row['item_id'] . "' text=\"" . str_replace('"', """, $row['item_nm']) . "\">"; getLevelFromDB($row['item_id']); print "</item>"; } } else { echo mysql_errno() . ": " . mysql_error() . " at " . __LINE__ . " line in " . __FILE__ . " file<br>"; } }
function getLevelFromDB($parent_id) { //get tree level from database taking parent id as incomming argument $sql = "SELECT item_id, item_nm FROM samples_tree WHERE item_parent_id={$parent_id} and GUID='" . $_SESSION["id"] . "' ORDER BY item_order"; $res = mysql_query($sql); if ($res) { while ($row = mysql_fetch_array($res)) { //create xml tag for tree node print "<item id='" . $row['item_id'] . "' text=\"" . str_replace('"', """, $row['item_nm']) . "\">"; //include child nodes getLevelFromDB($row['item_id']); //close xml tag for the node print "</item>"; } } else { echo mysql_errno() . ": " . mysql_error() . " at " . __LINE__ . " line in " . __FILE__ . " file<br>"; } }