PHP Classes

File: data/index.php

Recommend this page to a friend!
  Classes of Ujah Chigozie peter   PHP MySQL Hierarchical Tree   data/index.php   Download  
File: data/index.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP MySQL Hierarchical Tree
Retrieve and display hierarchy trees from MySQL
Author: By
Last change:
Date: 1 year ago
Size: 1,094 bytes


Class file image Download
__DIR__ . "/conn.php";
__DIR__ . "/../src/Hierarchical.php";
$hierarchy = new Hierarchical($conn, Hierarchical::CHART);
 When a user has logged in
 let the $username parameter be the user ref id
 and $name parameter be the display name of the current session user
$username = "vy7735";
$name = "Peter";
        <script type="text/javascript" src=""></script>
        <script type="text/javascript">
            google.charts.load('current', {packages:["orgchart"]});
            function drawChart() {
                var data = new google.visualization.DataTable();
                data.addColumn('string', 'Name');
                data.addColumn('string', 'Manager');
                data.addColumn('string', 'ToolTip');
                data.addRows(<?php echo $hierarchy->run($name, $username);?>);
                var chart = new google.visualization.OrgChart(document.getElementById('chart_div'));
                chart.draw(data, {'allowHtml':true});
        <div id="chart_div"></div>