function getTree($kat_id, $pic_id)
{
    include '../../share/global_config.php';
    include $sr . '/bin/share/db_connect1.php';
    $result2 = mysql_query("SELECT kat_id, kategorie FROM {$table4} WHERE parent='" . $kat_id . "' ORDER BY kategorie");
    while ($einzeln = @mysql_fetch_assoc($result2)) {
        if (hasChildKats($einzeln['kat_id'], $pic_id)) {
            $KA = $einzeln['kat_id'];
            $result3 = mysql_query("DELETE FROM {$table10} WHERE pic_id = '{$pic_id}' AND kat_id = '{$KA}'");
            $KAE = getTree($einzeln['kat_id'], $pic_id);
        } else {
            $KA = $einzeln['kat_id'];
            $result4 = mysql_query("DELETE FROM {$table10} WHERE pic_id = '{$pic_id}' AND kat_id = '{$KA}'");
        }
    }
}
 function getTree($kat_id, $k)
 {
     include '../../share/global_config.php';
     include $sr . '/bin/share/db_connect1.php';
     $result5 = mysql_query("SELECT * FROM {$table4} WHERE parent='{$kat_id}'");
     echo mysql_error();
     $sub_kats = "";
     $kat_arr = array();
     global $kat_arr;
     while ($einzeln = @mysql_fetch_assoc($result5)) {
         if (hasChildKats($einzeln['kat_id'])) {
             $k++;
             $kat_arr[$k][0] = $einzeln['kat_id'];
             $kat_arr[$k][1] = $einzeln['level'];
             $sub_kats = getTree($einzeln['kat_id'], $k);
         } else {
             $k++;
             $kat_arr[$k][0] = $einzeln['kat_id'];
             $kat_arr[$k][1] = $einzeln['level'];
         }
     }
     return $kat_arr;
 }