PHP Classes


Recommend this page to a friend!
  Classes of Ujah Chigozie peter   PHP MySQL Hierarchical Tree   Download  
Role: Documentation
Content type: text/markdown
Description: Read me
Class: PHP MySQL Hierarchical Tree
Retrieve and display hierarchy trees from MySQL
Author: By
Last change:
Date: 2 years ago
Size: 2,147 bytes


Class file image Download

PHP Hierarchical

Hierarchical is a simple php & mysql program to arrange users based on their rankings, it can also be used to represent data in a chain ranking. This libery will work very well with Google Organisation chart

alt text


Installation is super-easy via Composer:

composer require peterujah/hierarchical


Hierarchical can be use as an array, html or google organizations chart

  use Peterujah\NanoBlock\Hierarchical;
  $hierarchy = new Hierarchical($conn, Hierarchical::LIST);
  $hierarchy = new Hierarchical($conn, Hierarchical::HTML);
  $hierarchy = new Hierarchical($conn, Hierarchical::CHART);

Dump array

   $hierarchy = new Hierarchical($conn, Hierarchical::LIST);
   var_export($hierarchy->run("Peter", "vy7735"));

Display on google Organisation chart

  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("Peter", "vy7735");?>);
      var chart = new google.visualization.OrgChart(document.getElementById('chart_div'));
      chart.draw(data, {'allowHtml':true});

Initalisation options new Hierarchical($conn, Hierarchical::CHART)

| Options | Description | |-----------------|-------------------------------------------------------------------------------------| | LIST | Retrieve result as an array | | HTML | Retrieve result in HTML list | | CHART | Retrieve result in json data for google chart |