PHP code example of techlab / smartgrid

1. Go to this page and download the library: Download techlab/smartgrid library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

techlab / smartgrid example snippets


// Load the SmartGrid Library
$this->load->library('SmartGrid/Smartgrid');

// MySQL Query to get data
$sql = "SELECT * FROM employee"; 

// Column settings
$columns = array("employee_id"=>array("header"=>"Employee ID", "type"=>"label"),
                "employee_name"=>array("header"=>"Name", "type"=>"label"),
                "employee_designation"=>array("header"=>"Designation", "type"=>"label")
        );        
        
// Set the grid 
$this->smartgrid->set_grid($sql, $columns);

// Render the grid and assign to data array, so it can be print to on the view
$data['grid_html'] = $this->smartgrid->render_grid();    

// Load view
$this->load->view('example_smartgrid', $data);

// Print the grid html
echo $grid_html;