2017 © Pedro Peláez
 

library table

Create HTML tables that are easy to visualize and see what is going on.

image

bootpress/table

Create HTML tables that are easy to visualize and see what is going on.

  • Thursday, January 19, 2017
  • by BootPress
  • Repository
  • 1 Watchers
  • 0 Stars
  • 769 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

use BootPress\Table\Component as Table;

Packagist ![License MIT][badge-license] HHVM Tested ![PHP 7 Supported][badge-php] Build Status ![Code Climate][badge-code-climate] Test Coverage, (*1)

Create HTML tables that are easy to visualize and see what is going on., (*2)

Installation

Add the following to your composer.json file., (*3)

``` bash { "require": { "bootpress/table": "^1.0" } }, (*4)


## A Simple Example ```php <?php use BootPress\Table\Component as Table; $table = new Table; $html = $table->open(); $html .= $table->row(); $html .= $table->cell('', 'One'); $html .= $table->cell('', 'Two'); $html .= $table->cell('', 'Three'); $html .= $table->close(); echo $html;

That will give you three cells in a row:, (*5)

One Two Three

Or in other words:, (*6)

<table>
    <tbody>
        <tr>
            <td>One</td>
            <td>Two</td>
            <td>Three</td>
        </tr>
    </tbody>
</table>

Colspan and Rowspan

Notice that we use a syntax for attributes that keeps it compact, yet readable. Basically, every attribute is separated by a '|' (single pipe), and we drop the quotes., (*7)

$html = $table->open('border=1|class=special');
    $html .= $table->row();
    $html .= $table->cell('rowspan=2', 'Two Rows');
    $html .= $table->cell('', 'One');
    $html .= $table->cell('', 'Two');
    $html .= $table->row();
    $html .= $table->cell('colspan=2', 'Buckle my shoe');
$html .= $table->close();

echo $html;
Two Rows One Two
Buckle my shoe
<table border="1" class="special">
    <tbody>
        <tr>
            <td rowspan="2">Two Rows</td>
            <td>One</td>
            <td>Two</td>
        </tr><tr>
            <td colspan="2">Buckle my shoe</td>
        </tr>
    </tbody>
</table>

It is not necessary to pass a cells content to the method. It will still be wrapped appropriately., (*8)

$html = $table->open('border=1', 'Caption');
    $html .= $table->head();
    $html .= $table->cell('colspan=2') . 'Header';
    $html .= $table->row();
    $html .= $table->cell() . 'Three';
    $html .= $table->cell() . 'Four';
    $html .= $table->foot();
    $html .= $table->cell('colspan=2') . 'Shut the door';
$html .= $table->close();

echo $html;
Caption
Header
Three Four
Shut the door
<table border="1">
    <caption>Caption</caption>
    <thead>
        <tr>
            <th colspan="2">Header</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Three</td>
            <td>Four</td>
        </tr>
    </tbody>
    <tfoot>
        <tr>
            <td colspan="2"> Shut the door</td>
        </tr>
    </tfoot>
</table>

Nested Table

When you $table->close(), everything is reset and you can make another $table->open() without any problems. For nesting tables though, you'll need to create another instance of the class., (*9)

$t1 = new Table;
$t2 = new Table;

$html = $t1->open();
    $html .= $t1->row();
    $html .= $t1->cell('', 'Five');
    $html .= $t1->cell() . 'Six';
    $html .= $t1->cell();
        $html .= $t2->open('border=1');
            $html .= $t2->row();
            $html .= $t2->cell('', 'Pick');
            $html .= $t2->cell('', 'Up');
            $html .= $t2->cell('', 'Sticks');
        $html .= $t2->close();
$html .= $t1->close();
Five Six
Pick Up Sticks
<table>
    <tbody>
        <tr>
            <td>Five</td>
            <td>Six</td>
            <td>
                <table border="1">
                    <tbody>
                        <tr>
                            <td>Pick</td>
                            <td>Up</td>
                            <td>Sticks</td>
                        </tr>
                    </tbody>
                </table>
            </td>
        </tr>
    </tbody>
</table>

License

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

The Versions

19/01 2017

dev-master

9999999-dev https://www.bootpress.org/components/table.html

Create HTML tables that are easy to visualize and see what is going on.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kyle Gadd

html tables bootpress

19/10 2016

v1.0

1.0.0.0

Create HTML tables that are easy to visualize and see what is going on.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kyle Gadd

html tables bootpress