Here's a start for you <? /* Connect to database */
$sql = "SELECT * FROM categories ORDER BY parent_id,cat_id ASC"; $result = @mysql_query($sql) or die("Couldn't select categories."); $menu = array(); while ($row = mysql_fetch_array($result)) { $id = $row['cat_id']; $category = $row['category']; $pid = $row['parent_id']; $menu[$pid][$id] = $category; } function show_cats ($parent="", $indent="") { global $menu; foreach($menu as $key1 => $value1) { if ($key1 == $parent) {// if it's a top category print it foreach ($value1 as $key2 => $value2) { $catname = $value2; // $value2 same as $value1[$key2] $catID = $key2; echo str_repeat(" ", $indent); echo "<a href=\"search/show_results.php?catID=$catID\">$catname</a><br>"; show_cats($catID, $indent+1); } } } } // end show_cats function show_cats(); ?> --- Boris Kolev <[EMAIL PROTECTED]> wrote: > Hello php-general, > > Hi. > I want to know how i can export tree structure > from Mysql table to > XML > mysql table structure is: > ID - Group Unique Id > P_ID - Parent Id > Name - Name of group > > I want to make XML whit tree structure. Can some > body help me! > > > -- > Best regards, > Boris > mailto:[EMAIL PROTECTED] > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php