Beispiel #1
0
function build_child($oldID)
{
    // Refer to the global array defined at the top of this script
    global $exclude, $depth, $db, $tprefix, $editid, $tld;
    $tempTree = '';
    $child_sql = "SELECT * FROM `{$tprefix}" . "_category` WHERE parent_id=" . $oldID;
    //echo $child_sql ;
    $child_query = $db->query($child_sql);
    while ($child = $child_query->fetch_array()) {
        if ($child['cat_id'] != $child['parent_id']) {
            for ($c = 0; $c < $depth; $c++) {
                $tempTree .= "&nbsp;";
            }
            $tempTree .= "- " . '<input type="checkbox" name="category[]" value="' . $child['cat_id'] . '" ' . check_category($editid, $child['cat_id']) . ' />' . $child['cat_label'] . '<a href="' . $tld . '/manage/settings/category-form.php?parent_id=' . $child['cat_id'] . '&parent_name=' . $child['cat_label'] . '">[+]</a><br>';
            $depth++;
            // Incriment depth b/c we're building this child's child tree  (complicated yet???)
            $tempTree .= build_child($child['cat_id']);
            // Add to the temporary local tree
            $depth--;
            // Decrement depth b/c we're done building the child's child tree.
            ARRAY_PUSH($exclude, $child['cat_id']);
            // Add the item to the exclusion list
        }
    }
    return $tempTree;
    // Return the entire child tree
}
Beispiel #2
0
function build_child($oldID)
{
    // Refer to the global array defined at the top of this script
    global $exclude, $depth, $db, $tprefix, $editid;
    $tempR = array();
    $child_sql = "SELECT * FROM `mu" . "_category` WHERE parent_id=" . $oldID;
    //echo $child_sql ;
    $child_query = $db->query($child_sql);
    $k = 0;
    while ($child = $child_query->fetch_array()) {
        if ($child['cat_id'] != $child['parent_id']) {
            for ($c = 0; $c < $depth; $c++) {
            }
            $tempR[$k]['cat_id'] = $child['cat_id'];
            $tempR[$k]['label'] = $child['cat_label'];
            $depth++;
            // Increment depth b/c we're building this child's child tree  (complicated yet???)
            if (build_child($child['cat_id']) != FALSE) {
                $tempR[$k]['child'] = build_child($child['cat_id']);
            }
            $depth--;
            // Decrement depth b/c we're done building the child's child tree.
            ARRAY_PUSH($exclude, $child['cat_id']);
            // Add the item to the exclusion list
            $k++;
        }
    }
    if (!empty($tempR)) {
        return $tempR;
    } else {
        return FALSE;
    }
    // Return the entire child tree
}
Beispiel #3
0
 function build_child($oldID)
 {
     $indent = "";
     $tempTree = "";
     global $exclude, $depth;
     $child_query = mysql_query("SELECT * FROM category WHERE par_id=" . $oldID . " ORDER BY name");
     while ($child = mysql_fetch_array($child_query)) {
         if ($child['id'] != $child['par_id']) {
             for ($c = 0; $c < $depth; $c++) {
                 $tempTree .= "";
                 $indent .= "&nbsp;&nbsp;";
             }
             $tempTree .= "<tr><td> " . $indent . $child['name'] . "</td><td><a href='edit_category.php?cid=" . $child['id'] . "'>edit</a></td><td><a href='categories.php?cid=" . $child['id'] . "&act=del'>delete</a></td></tr>";
             $indent = "";
             $depth++;
             $tempTree .= build_child($child['id']);
             $depth--;
             @array_push($exclude, $child['id']);
         }
     }
     return $tempTree;
 }