PHP Classes

PHP MySQL Hierarchical Tree: Retrieve and display hierarchy trees from MySQL

Recommend this page to a friend!
  Info   View files Documentation   View files View files (8)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 172 All time: 8,812 This week: 78Up
Version License PHP version Categories
hierarchical 1.0.0GNU General Publi...5Algorithms, PHP 5, Graphics, Web serv..., D...
Description 

Author

This class can retrieve and display hierarchy trees from MySQL.

It can query a MySQL database table that contains records of nodes of a tree of elements that form a hierarchy.

The class can also return a JSON data structure with the hierarchy information that is suitable to pass to Google Chart API so it can render the hierarchy tree as an image that can be displayed in the current Web page.

Innovation Award
PHP Programming Innovation award nominee
February 2022
Number 4
Hierarchies represent relations between people or other types of related entities. The hierarchy structure determines which entities are in command of other entities.

Hierarchies can be stored in databases using table records that express what entities are below or above in the hierarchy tree.

This class can retrieve a hierarchy tree structure from a MySQL database table to easily visualize using the Google Charts API.

Manuel Lemos
Picture of Ujah Chigozie peter
  Performance   Level  
Name: Ujah Chigozie peter <contact>
Classes: 25 packages by
Country: Nigeria Nigeria
Innovation award
Innovation award
Nominee: 11x

Recommendations

I need a PHP class for mind map generation
Read a hierarchical data structure and generate a graphical map

Documentation

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

Installation is super-easy via Composer:

composer require peterujah/hierarchical

USAGES

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"]});
	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("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 |


  Files folder image Files  
File Role Description
Files folder imagedata (3 files)
Files folder imagesrc (1 file)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file package.json Data Auxiliary data
Accessible without login Plain text file README.md Doc. Read me

  Files folder image Files  /  data  
File Role Description
  Accessible without login Plain text file conn.php Aux. Auxiliary script
  Accessible without login Plain text file hierarchical_data.sql Data Auxiliary data
  Accessible without login Plain text file index.php Example Example script

  Files folder image Files  /  src  
File Role Description
  Plain text file Hierarchical.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:172
This week:0
All time:8,812
This week:78Up