2017 © Pedro PelĂĄez
 

library ctable

Classes for HTML Tables

image

edtau/ctable

Classes for HTML Tables

  • Tuesday, November 17, 2015
  • by edtau
  • Repository
  • 1 Watchers
  • 0 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

CTable simple PHP class to render HTML tables from array

Latest Stable Version, (*1)

By Eddie Taube (eddie.taube@gmail.com), (*2)

CTable is intended to be used with Anax-MVC (https://github.com/mosbth/Anax-MVC) but can also easy be used for a custom PHP application., (*3)

Installation

To install the package you can use composer, (*4)

composer require edtau/ctable

, download the zipfile or clone it through github. For use with ANAX-MVC it is recommended that you copy the Table folder from src to app src. In the folder you find two classes CTable.php and TableController.php. if you want to test CTable copy the file table.php from the package folder webroot then simple run table.php from your application to test the different tables., (*5)

Installation

If you want to use the package in your own custom application there is a couple of things you have to do for the class to work., (*6)

  1. Remove from CTable:
implements \Anax\DI\IInjectionAware
  1. And remove the code from CTable:
use \Anax\DI\TInjectable;
  1. Now the class should work in your custom project.

Usage

You have two different options when you want to generate a html-table., (*7)

  1. First option
  $table = new CTable();
  $data = array(
           array('Förnamn', 'Efternamn', 'Ålder'),
           array('Anders', 'Andersson', '40'),
           array('Stig', 'Larsson', '41'),
           array('Anna', 'Svensson', '45')
       );
  $html = $table->table($data);

$html now cointains your generated table the first array automatic becomes the headers of your table. You can also set the id by sending the param to your table when getting the html., (*8)

$html = $table->table($data,$myId);, (*9)

  1. Second option set the header for a custom table
$this->table->setHeader(array('Förnamn', 'Efternamn', 'Ålder'));
       $array = array(
           array('Anders', 'Andersson', '40'),
           array('Stig', 'Larsson', '41'),
           array('Anna', 'Svensson', '45'),
           array('Bengt', 'Andersson', '40'),
           array('Karin', 'Larsson', '41'),
           array('Ulf', 'Svensson', '45')
       );
       $html = $this->table->table($array);

The code will generate a table based on your header of course you still have the option to send param id to the table method., (*10)

License

This software is free software and carries a MIT license., (*11)

Todo

  • Add support for CSS classes
  • Add support for striped tables

History

v1.0* (2015-11-10), (*12)

The Versions

17/11 2015

dev-master

9999999-dev http://eddie.taube.se/

Classes for HTML Tables

  Sources   Download

MIT

The Requires

  • php >=5.4

 

html table