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: 7 months ago
Size: 1,094 bytes
 

Contents

Class file image Download
<?php
session_start
();
include_once
__DIR__ . "/conn.php";
include_once
__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";
?>
<html>
  <head>
        <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
        <script type="text/javascript">
            google.charts.load('current', {packages:["orgchart"]});
            google.charts.setOnLoadCallback(drawChart);
            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});
            }
        </script>
    </head>
      <body>
        <div id="chart_div"></div>
      </body>
</html>


For more information send a message to info at phpclasses dot org.