\CI_Table

HTML Table Generating Class

Lets you create tables manually or from database result objects, or arrays.

Summary

Methods
Properties
Constants
__construct()
set_template()
set_heading()
make_columns()
set_empty()
add_row()
set_caption()
generate()
clear()
$rows
$heading
$auto_heading
$caption
$template
$newline
$empty_cells
$function
No constants found
_prep_args()
_set_from_db_result()
_set_from_array()
_compile_template()
_default_template()
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$rows

$rows : array

Data for table rows

Type

array

$heading

$heading : array

Data for table heading

Type

array

$auto_heading

$auto_heading : boolean

Whether or not to automatically create the table header

Type

boolean

$caption

$caption : string

Table caption

Type

string

$template

$template : array

Table layout template

Type

array

$newline

$newline : string

Newline setting

Type

string

$empty_cells

$empty_cells : string

Contents of empty cells

Type

string

$function

$function : \function

Callback for custom table layout

Type

\function

Methods

__construct()

__construct(array  $config = array()) : void

Set the template from the table config file if it exists

Parameters

array $config

(default: array())

set_template()

set_template(array  $template) : boolean

Set the template

Parameters

array $template

Returns

boolean

set_heading()

set_heading(  $args = array()) : \CI_Table

Set the table heading

Can be passed as an array or discreet params

Parameters

$args

Returns

\CI_Table

make_columns()

make_columns(array  $array = array(), integer  $col_limit) : array

Set columns. Takes a one-dimensional array as input and creates a multi-dimensional array with a depth equal to the number of columns. This allows a single array with many elements to be displayed in a table that has a fixed column count.

Parameters

array $array
integer $col_limit

Returns

array

set_empty()

set_empty(mixed  $value) : \CI_Table

Set "empty" cells

Can be passed as an array or discreet params

Parameters

mixed $value

Returns

\CI_Table

add_row()

add_row(  $args = array()) : \CI_Table

Add a table row

Can be passed as an array or discreet params

Parameters

$args

Returns

\CI_Table

set_caption()

set_caption(string  $caption) : \CI_Table

Add a table caption

Parameters

string $caption

Returns

\CI_Table

generate()

generate(mixed  $table_data = NULL) : string

Generate the table

Parameters

mixed $table_data

Returns

string

clear()

clear() : \CI_Table

Clears the table arrays. Useful if multiple tables are being generated

Returns

\CI_Table

_prep_args()

_prep_args(  $args) : array

Prep Args

Ensures a standard associative array format for all cell data

Parameters

$args

Returns

array

_set_from_db_result()

_set_from_db_result(\CI_DB_result  $object) : void

Set table data from a database result object

Parameters

\CI_DB_result $object

Database result object

_set_from_array()

_set_from_array(array  $data) : void

Set table data from an array

Parameters

array $data

_compile_template()

_compile_template() : void

Compile Template

_default_template()

_default_template() : array

Default Template

Returns

array