webdivane/table

This package is abandoned and no longer maintained. The author suggests using the pimarinov/table package instead.

A php table helper.

1.3.0 2019-03-30 08:03 UTC

This package is auto-updated.

Last update: 2022-04-03 08:05:20 UTC


README

Build Status Scrutinizer Code Quality MIT license

Installation

You can install the package via composer:

composer require webdivane/table

Usage

    table::create("users", "id", "desc", 50);

        table::$cols[] = ["ID", "id", ["width"=>"50px"]];
        table::$cols[] = ["Name", "name"];
        table::$cols[] = ["Email", "email"];
        table::$cols[] = ["test","test",["sort"=>false]];
        table::$cols[] = ["Created", "created_at_formatted", ["sort"=>"created_at","width"=>"130px"]];
        table::$cols[] = ["Updated", "updated_at_formatted", ["sort"=>"updated_at","width"=>"130px"]];
        table::$cols[] = ["...", "lnks", ["class"=>"links","sort"=>false]];

    table::execute('SELECT * FROM users');

        foreach(table::$data as &$cells){
            $cells = get_object_vars($cells); //object -> array

            if(table::$export === false){
                $cells['id'] = sprintf('<a href="/users/%1$d" title="View">%1$d</a>', $cells['id']);
                $cells['email'] = sprintf('<a href="mailto:%1$s" title="Send email">%1$s</a>', $cells['email']);
            }
        }

        table::$attributes["table"]["class"] = "table-striped table-sm table-hover table-bordered";

    table::load();

License

The MIT License (MIT). Please see License File for more information.