Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: dtree menu help

  1. #1
    New Coder
    Join Date
    Dec 2007
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts

    dtree menu help

    hi ! i need to any code for dtree menu for dynamic data view as php/mysql database . exp :
    ID1
    1
    2
    3
    ID2
    1
    2
    3
    . . . . . . . note : add one category in admin panel so add in dtree menu . thanks . regards

  • #2
    Regular Coder ninnypants's Avatar
    Join Date
    Apr 2008
    Location
    Utah
    Posts
    504
    Thanks
    10
    Thanked 47 Times in 47 Posts
    Are you trying to pull the info out of database and print it to the page?

  • #3
    Regular Coder
    Join Date
    Mar 2008
    Posts
    103
    Thanks
    1
    Thanked 8 Times in 8 Posts
    heres a on the fly script no guarantees for safty or usabilities....USE FOR A EXAMPLE ONLY
    PHP Code:
    <?php
    session_start
    ();
    require(
    'config.php'); //set that up yourself should not be to hard.
    /*
    As of this point forward I am running under the impression, that you are using a login system already that has moderator, administrator, guest, and normal users written out in 'long' form naming. I am also assuming that sessions are used.
    */
    $userlevel $_SESSION['user_level'];
    $permissions = array(administrator => array('add_tab''add_item''edit_tab''edit_item''delete_tab''delete_item''view'), moderator => array('add_item''edit_item''delete_item''view'), normal => array('view'), guest => array('view')); //one long array right there O.o
        
    for($i 0$i <= count($permissions[$userlevel]); $i++){
            switch(
    $permission[$userlevel][$i]){
                case(
    'add_tab'):
                    echo(
    "<a href=\"menu.php?mode=$permissions[$userlevel][$i]\">$permission[$userlevel][$i]</a>");
                break;
                case(
    'add_item'):
                    echo(
    "<a href=\"menu.php?mode=$permissions[$userlevel][$i]\">$permission[$userlevel][$i]</a>");
                break;
                case(
    'edit_tab'):
                    echo(
    "<a href=\"menu.php?mode=$permissions[$userlevel][$i]\">$permission[$userlevel][$i]</a>");
                break;
                case(
    'edit_item'):
                    echo(
    "<a href=\"menu.php?mode=$permissions[$userlevel][$i]\">$permission[$userlevel][$i]</a>");
                break;
                case(
    'delete_tab'):
                    echo(
    "<a href=\"menu.php?mode=$permissions[$userlevel][$i]\">$permission[$userlevel][$i]</a>");
                break;
                case(
    'delete_item'):
                    echo(
    "<a href=\"menu.php?mode=$permissions[$userlevel][$i]\">$permission[$userlevel][$i]</a>");
                break;
                case(
    'view'):
                    
    $view true;
                break;
                default:
                    die(
    'unknown condition');
                break;
            }
        }
        if(isset(
    $_GET['mode'])){
            
    $mode $_GET['mode'];
                if(!
    in_array($permissions[$userlevel])){
                    die(
    'incorect permissions');
                }
                else{
                    echo(
    'put the tab name or item name you want here<br />');
                    echo(
    "<form action=\"menu.php?mode=$mode&step=2\" action=\"post\">");
                    echo(
    '<input type="textbox" name="name" value="name goes here" />');
                    echo(
    '<input type="submit" />');
                    echo(
    '</form><br /><br /><br />');
                    echo(
    'or if you are editing a item use this form here');
                    echo(
    "<form action=\"menu.php?mode=$mode&step=2\" action=\"post\">");
                    echo(
    '<input type="textbox" name="name" value="old name goes here" />');
                    echo(
    '<input type="textbox" name="nametwo" value="new name here" />');
                    echo(
    '<input type="submit" />');
                    echo(
    '</form>');
                }
        }
        if(
    $_GET['step'] == && isset($_GET['mode']) && isset($_POST['name'])){
            
    $name $_POST['name'];
            
    $nametwo $_POST['nametwo'];
                if(
    $mode == 'add_tab' || $mode == 'edit_tab' || $mode == 'delete_tab'){
                    
    $type 'tab';
                }
                elseif(
    $mode == 'add_item' || $mode == 'edit_item' || $mode == 'delete_item'){
                    
    $type 'item';
                }
                if(!
    in_array($permissions[$userlevel])){
                    die(
    'incorect permissions');
                }
                if(
    $mode == 'add_tab' || $mode == 'add_item'){
                    
    mysql_query("INSERT INTO menu (type, name) VALUES('$type', '$name' ) ") or die(mysql_error());  
                }
                elseif(
    $mode == 'edit_tab' || $mode == 'edit_item'){
                    
    mysql_query("UPDATE menu SET name='$nametwo' WHERE type='$type' AND name='$name' ) ") or die(mysql_error());  
                }
                elseif(
    $mode == 'delete_tab' || $mode == 'delete_item'){
                    
    mysql_query("DELETE FROM menu WHERE type='$type' AND name='$name' ) ") or die(mysql_error());  
                }
            echo(
    'operation successfull');
        }
    ?>
    YOU MUST STILL MAKE THE PART TO GENERATE THE MENU THIS WILL ONLY MANAGE THE MENU.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •