Page 2 of 2 First 12
  • Jump to page:
    #16
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    14
    Rep Power
    0
    I got it to work using the For loops instead of the While loops!




    PHP Code:
    <?php
        
    require("http://www.trutechunlimited.com/orgchart/_include/constants.html");
        require_once(
    "http://www.trutechunlimited.com/orgchart/_include/functions.html");

        
    $connection mysql_connect(DB_SERVER,DB_USER,DB_PASS);
        if (!
    $connection){ 
        die(
    "Failed to connect to mysql");
        }
        
        
    $db_select mysql_select_db("kirklog1_orgchart"$connection);
        if (!
    $db_select) {
            die(
    "Failed to connect");
        }
    ?>

    <html>
        <head>
        <title>Org-Chart</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta http-equiv="X-UA-Compatible" content="IE=9" />
        <link href="http://www.trutechunlimited.com/orgchart/_css/main.css" rel="stylesheet" type="text/css" />
        </head>
            <body>
                
                
                    <!--content output starts here-->
                    
                    <?php    
                    $l1ver 
    0;
                    
    $l2ver 0;
                    
    $l3ver 0;
                    
    $l4ver 0;
                    
                            
    //prepare initial loop data
                            
    $lev1_set mysql_query("SELECT id, name, title, supername 
                                                FROM orgchart
                                                WHERE supername = 'none'
                                                ORDER BY name ASC"
    $connection);    
                            
    //fist output layer                    
                            
    for (;$lev1 mysql_fetch_assoc($lev1_set);div()){
                                
                                
    $lev1name $lev1['name'];
                                
    $lev1title $lev1['title'];
                                
                                
    output_bubble($lev1name$lev1title);
                                        
                                        
    $l2ver 0;
                                        
    $parent1 $lev1['name'];
                                        
                                        
    //prepare next loop data
                                        
    $lev2_set mysql_query("SELECT id, name, title, supername 
                                                FROM orgchart
                                                WHERE supername = '
    $lev1name'
                                                ORDER BY name ASC"
    $connection);
                                                
                                        
    //second output layer
                                        
    for (;$lev2 mysql_fetch_assoc($lev2_set); div()) {
                                            
                                            
                                            if (
    $l2ver == 0) {
                                                echo 
    "<br />\n";
                                            }    
                                            
                                            
    $lev2name $lev2['name'];
                                            
    $lev2title $lev2['title'];
                                            
                                            
    output_bubble($lev2name$lev2title);
                                            
                                                    
    $l3ver 0;
                                                    
    $l2ver++;
                                                    
                                                    
                                                    
    //prepare next loop data
                                                    
    $lev3_set mysql_query("SELECT id, name, title, supername 
                                                                            FROM orgchart
                                                                            WHERE supername = '
    $lev2name'
                                                                            ORDER BY name ASC"
    $connection);
                                                            
                                                        
    //third output layer                
                                                        
    for (;$lev3 mysql_fetch_assoc($lev3_set); div()) {
                                                        
                                                        
                                                            
                                                        if (
    $l3ver == 0) {
                                                            echo 
    "<br />";
                                                        }    
                                                        
                                                        
    $lev3name $lev3['name'];
                                                        
    $lev3title $lev3['title'];
                                                        
                                                        
    output_bubble($lev3name$lev3title);
                                                                
                                                                
    $l4ver 0;
                                                                
    $l3ver++;
                                                                
                                                    
    //prepare next loop data
                                                    
    $lev4_set mysql_query("SELECT id, name, title, supername 
                                                                            FROM orgchart
                                                                            WHERE supername = '
    $lev3name'
                                                                            ORDER BY name ASC"
    $connection);

                                                                for (;
    $lev4 mysql_fetch_assoc($lev4_set);div()) {
                                                                    if (
    $l4ver == 0) {
                                                                        echo 
    "<br />\n";
                                                                    }
                                                                    
                                                                    
    $lev4name $lev4['name'];
                                                                    
    $lev4title $lev4['title'];
                                                                    
                                                                    
    output_bubble($lev4name$lev4title);
                                                                    
                                                                            
                                                                            
    $l4ver++;
                                                                            
                                                                }
                                            }
                                        }
                            }
    // if (the $lev1['name'] is the last 'name' in the array) {
    //        echo "</div>";
    // } else {
    //         echo "<br />";
    //    }
                      
    ?>

            </body>
    </html>

    <?php mysql_close($connection); ?>
  2. #17
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2009
    Posts
    677
    Rep Power
    7
    Congrats! Just a note. If you wish, the closing db connection at bottom isn't really needed. Connection is only open during the process n closed when done. Good job. :-p
  4. #18
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    14
    Rep Power
    0
    Thank you so very much for all of your help, im still new to PHP but ive learned a ton on this project, im running my final tests now and theyre coming out great! Thanks again!
    Ill definitely stick around the forums here.
    Take care and enjoy the rest of your day.
Page 2 of 2 First 12
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo