From 98d3b54265132dccb3f1c3e05ed4dae1cc7645b9 Mon Sep 17 00:00:00 2001 From: Derek Allard Date: Fri, 14 Dec 2007 13:13:21 +0000 Subject: Fixed a typo in the table library docs. --- user_guide/changelog.html | 2 +- user_guide/libraries/table.html | 293 +--------------------------------------- 2 files changed, 2 insertions(+), 293 deletions(-) (limited to 'user_guide') diff --git a/user_guide/changelog.html b/user_guide/changelog.html index 6fcdbaadb..babb020c5 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -1 +1 @@ - CodeIgniter User Guide : Change Log

CodeIgniter User Guide Version 1.5.4


Change Log

Version 1.5.5

Release Date: -- still in development

Version 1.5.4

Release Date: July 12, 2007

Version 1.5.3

Release Date: April 15, 2007

Version 1.5.2

Release Date: February 13, 2007

Version 1.5.1

Release Date: November 23, 2006

Version 1.5.0.1

Release Date: October 31, 2006

Version 1.5.0

Release Date: October 30, 2006

Version 1.4.1

Release Date: September 21, 2006

Version 1.4.0

Release Date: September 17, 2006

Version 1.3.3

Release Date: June 1, 2006

Version 1.3.2

Release Date: April 17, 2006

Version 1.3.1

Release Date: April 11, 2006

Version 1.3

Release Date: April 3, 2006

Version 1.2

Release Date: March 21, 2006

Version Beta 1.1

Release Date: March 10, 2006

Version Beta 1.0

Release Date: February 28, 2006

First publicly released version.

\ No newline at end of file + CodeIgniter User Guide : Change Log

CodeIgniter User Guide Version 1.5.4


Change Log

Version 1.5.5

Release Date: -- still in development

Version 1.5.4

Release Date: July 12, 2007

Version 1.5.3

Release Date: April 15, 2007

Version 1.5.2

Release Date: February 13, 2007

Version 1.5.1

Release Date: November 23, 2006

Version 1.5.0.1

Release Date: October 31, 2006

Version 1.5.0

Release Date: October 30, 2006

Version 1.4.1

Release Date: September 21, 2006

Version 1.4.0

Release Date: September 17, 2006

Version 1.3.3

Release Date: June 1, 2006

Version 1.3.2

Release Date: April 17, 2006

Version 1.3.1

Release Date: April 11, 2006

Version 1.3

Release Date: April 3, 2006

Version 1.2

Release Date: March 21, 2006

Version Beta 1.1

Release Date: March 10, 2006

Version Beta 1.0

Release Date: February 28, 2006

First publicly released version.

\ No newline at end of file diff --git a/user_guide/libraries/table.html b/user_guide/libraries/table.html index 4ce948e60..0e627d120 100644 --- a/user_guide/libraries/table.html +++ b/user_guide/libraries/table.html @@ -1,292 +1 @@ - - - - -CodeIgniter User Guide : HTML Table Class - - - - - - - - - - - - - - - - - - - - - - -
- - - - - -

CodeIgniter User Guide Version 1.5.4

-
- - - - - - - - - -
- - -
- - - -
- - -

HTML Table Class

- -

The Table Class provides functions that enable you to auto-generate HTML tables from arrays or database result sets.

- -

Initializing the Class

- -

Like most other classes in CodeIgniter, the Table class is initialized in your controller using the $this->load->library function:

- -$this->load->library('table'); -

Once loaded, the Table library object will be available using: $this->table

- - -

Examples

- -

Here is an example showing how you can create a table from a multi-dimensional array. -Note that the first array index will become the table heading (or you can set your own headings using the -set_heading() function described in the function reference below).

- - -$this->load->library('table');
-
-$data = array(
-             array('Name', 'Color', 'Size'),
-             array('Fred', 'Blue', 'Small'),
-             array('Mary', 'Red', 'Large'),
-             array('John', 'Green', 'Medium')
-             );
-
-echo $this->table->generate($data); -
- -

Here is an example of a table created from a database query result. The table class will automatically generate the -headings based on the table names (or you can set your own headings using the set_heading() function described -in the function reference below).

- - -$this->load->library('table');
-
-$query = $this->db->query("SELECT * FROM my_table");
-
-echo $this->table->generate($query); -
- - -

Here is an example showing how you might create a table using discreet parameters:

- - -$this->load->library('table');
-
-$this->table->set_heading('Name', 'Color', 'Size');
-
-$this->table->add_row('Fred', 'Blue', 'Small');
-$this->table->add_row('Mary', 'Red', 'Large');
-$this->table->add_row('John', 'Green', 'Medium');
-
-echo $this->table->generate(); -
- -

Here is the same example, except instead of individual parameters, arrays are used:

- - -$this->load->library('table');
-
-$this->table->set_heading(array('Name', 'Color', 'Size'));
-
-$this->table->add_row(array('Fred', 'Blue', 'Small'));
-$this->table->add_row(array('Mary', 'Red', 'Large'));
-$this->table->add_row(array('John', 'Green', 'Medium'));
-
-echo $this->table->generate(); -
- - -

Changing the Look of Your Table

- -

The Table Class permits you to set a table template with which you can specify the design of your layout. Here is the template -prototype:

- - -$tmpl = array (
-                    'table_open'          => '<table border="0" cellpadding="4" cellspacing="0">',
-
-                    'heading_row_start'   => '<tr>',
-                    'heading_row_end'     => '</tr>',
-                    'heading_cell_start'  => '<th>',
-                    'heading_cell_end'    => '</th>',
-
-                    'row_start'           => '<tr>',
-                    'row_end'             => '</tr>',
-                    'cell_start'          => '<td>',
-                    'cell_end'            => '</td>',
-
-                    'row_alt_start'       => '<tr>',
-                    'row_alt_end'         => '</tr>',
-                    'cell_alt_start'      => '<td>',
-                    'cell_alt_end'        => '</td>',
-
-                    'table_close'         => '</table>'
-              );
- -
-$this->table->set_template($tmpl); -
- -

Note:  You'll notice there are two sets of "row" blocks in the template. These permit you to create alternating row colors or design elements that alternate with each -iteration of the row data.

- -

You are NOT required to submit a complete template. If you only need to change parts of the layout you can simply submit those elements. -In this example, only the table opening tag is being changed:

- - -$tmpl = array ( 'table_open'  => '<table border="1" cellpadding="2" cellspacing="1" class="mytable">' );
- -
-$this->table->set_template($tmpl); -
- -
-

Function Reference

- -

$this->table->generate()

-

Returns a string containing the generated table. Accepts an optional parameter which can be an array or a database result object.

- -

$this->table->set_caption()

- -

Permits you to add a caption to the table.

- -$this->table->set_caption('Colors'); - -

$this->table->set_heading()

- -

Permits you to set the table heading. You can submit an array or discreet params:

- -$this->table->set_heading('Name', 'Color', 'Size'); -$this->table->set_heading(array('Name', 'Color', 'Size')); - -

$this->table->add_row()

- -

Permits you to add a row to your table. You can submit an array or discreet params:

- -$this->table->add_row('Blue', 'Red', 'Green'); -$this->table->add_row(array('Blue', 'Red', 'Green')); - - -

$this->table->make_columns()

- -

This function takes a one-dimensional array as input and creates -a multi-dimensional array with a depth equal to the number of -columns desired. This allows a single array with many elements to be -displayed in a table that has a fixed column count. Consider this example:

- - -$list = array('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve');
-
-$new_list = $this->table->make_columns($list, 3);
-
-$this->table->generate($new_list)
-
-// Generates a table with this prototype
-
-<table border="0" cellpadding="4" cellspacing="0">
-<tr>
-<td>one</td><td>two</td><td>three</td>
-</tr><tr>
-<td>four</td><td>five</td><td>six</td>
-</tr><tr>
-<td>seven</td><td>eight</td><td>nine</td>
-</tr><tr>
-<td>ten</td><td>eleven</td><td>twelve</td></tr>
-</table>
- - - -

$this->table->set_template()

- -

Permits you to set your template. You can submit a full or partial template.

- - -$tmpl = array ( 'table_open'  => '<table border="1" cellpadding="2" cellspacing="1" class="mytable">' );
- -
-$this->table->set_template($tmpl); -
- - -

$this->table->set_empty()

- -

Let's you set a default value for use in any table cells that are empty. You might, for example, set a non-breaking space:

- - -$this->table->set_empty("&nbsp;"); - - -

$this->table->clear()

- -

Lets you clear the table heading and row data. If you need to show multiple tables with different data you should -to call this function after each table has been generated to empty the previous table information. Example:

- - -$this->load->library('table');
-
-$this->table->set_heading('Name', 'Color', 'Size');
-$this->table->add_row('Fred', 'Blue', 'Small');
-$this->table->add_row('Mary', 'Red', 'Large');
-$this->table->add_row('John', 'Green', 'Medium');
-
-echo $this->table->generate();
-
-$this->table->clear();
-
-$this->table->set_heading('Name', 'Day', 'Delivery');
-$this->table->add_row('Fred', 'Wednesday', 'Express');
-$this->table->add_row('Mary', 'Monday', 'Air');
-$this->table->add_row('John', 'Saturday', 'Overnight');
-
-echo $this->table->generate(); -
- -
- - - - - - - \ No newline at end of file + CodeIgniter User Guide : HTML Table Class

CodeIgniter User Guide Version 1.5.4


HTML Table Class

The Table Class provides functions that enable you to auto-generate HTML tables from arrays or database result sets.

Initializing the Class

Like most other classes in CodeIgniter, the Table class is initialized in your controller using the $this->load->library function:

$this->load->library('table');

Once loaded, the Table library object will be available using: $this->table

Examples

Here is an example showing how you can create a table from a multi-dimensional array. Note that the first array index will become the table heading (or you can set your own headings using the set_heading() function described in the function reference below).

$this->load->library('table');

$data = array(
             array('Name', 'Color', 'Size'),
             array('Fred', 'Blue', 'Small'),
             array('Mary', 'Red', 'Large'),
             array('John', 'Green', 'Medium')
             );

echo $this->table->generate($data);

Here is an example of a table created from a database query result. The table class will automatically generate the headings based on the table names (or you can set your own headings using the set_heading() function described in the function reference below).

$this->load->library('table');

$query = $this->db->query("SELECT * FROM my_table");

echo $this->table->generate($query);

Here is an example showing how you might create a table using discreet parameters:

$this->load->library('table');

$this->table->set_heading('Name', 'Color', 'Size');

$this->table->add_row('Fred', 'Blue', 'Small');
$this->table->add_row('Mary', 'Red', 'Large');
$this->table->add_row('John', 'Green', 'Medium');

echo $this->table->generate();

Here is the same example, except instead of individual parameters, arrays are used:

$this->load->library('table');

$this->table->set_heading(array('Name', 'Color', 'Size'));

$this->table->add_row(array('Fred', 'Blue', 'Small'));
$this->table->add_row(array('Mary', 'Red', 'Large'));
$this->table->add_row(array('John', 'Green', 'Medium'));

echo $this->table->generate();

Changing the Look of Your Table

The Table Class permits you to set a table template with which you can specify the design of your layout. Here is the template prototype:

$tmpl = array (
                    'table_open'          => '<table border="0" cellpadding="4" cellspacing="0">',

                    'heading_row_start'   => '<tr>',
                    'heading_row_end'     => '</tr>',
                    'heading_cell_start'  => '<th>',
                    'heading_cell_end'    => '</th>',

                    'row_start'           => '<tr>',
                    'row_end'             => '</tr>',
                    'cell_start'          => '<td>',
                    'cell_end'            => '</td>',

                    'row_alt_start'       => '<tr>',
                    'row_alt_end'         => '</tr>',
                    'cell_alt_start'      => '<td>',
                    'cell_alt_end'        => '</td>',

                    'table_close'         => '</table>'
              );

$this->table->set_template($tmpl);

Note:  You'll notice there are two sets of "row" blocks in the template. These permit you to create alternating row colors or design elements that alternate with each iteration of the row data.

You are NOT required to submit a complete template. If you only need to change parts of the layout you can simply submit those elements. In this example, only the table opening tag is being changed:

$tmpl = array ( 'table_open'  => '<table border="1" cellpadding="2" cellspacing="1" class="mytable">' );

$this->table->set_template($tmpl);

Function Reference

$this->table->generate()

Returns a string containing the generated table. Accepts an optional parameter which can be an array or a database result object.

$this->table->set_caption()

Permits you to add a caption to the table.

$this->table->set_caption('Colors');

$this->table->set_heading()

Permits you to set the table heading. You can submit an array or discreet params:

$this->table->set_heading('Name', 'Color', 'Size'); $this->table->set_heading(array('Name', 'Color', 'Size'));

$this->table->add_row()

Permits you to add a row to your table. You can submit an array or discreet params:

$this->table->add_row('Blue', 'Red', 'Green'); $this->table->add_row(array('Blue', 'Red', 'Green'));

$this->table->make_columns()

This function takes a one-dimensional array as input and creates a multi-dimensional array with a depth equal to the number of columns desired. This allows a single array with many elements to be displayed in a table that has a fixed column count. Consider this example:

$list = array('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve');

$new_list = $this->table->make_columns($list, 3);

$this->table->generate($new_list);

// Generates a table with this prototype

<table border="0" cellpadding="4" cellspacing="0">
<tr>
<td>one</td><td>two</td><td>three</td>
</tr><tr>
<td>four</td><td>five</td><td>six</td>
</tr><tr>
<td>seven</td><td>eight</td><td>nine</td>
</tr><tr>
<td>ten</td><td>eleven</td><td>twelve</td></tr>
</table>

$this->table->set_template()

Permits you to set your template. You can submit a full or partial template.

$tmpl = array ( 'table_open'  => '<table border="1" cellpadding="2" cellspacing="1" class="mytable">' );

$this->table->set_template($tmpl);

$this->table->set_empty()

Let's you set a default value for use in any table cells that are empty. You might, for example, set a non-breaking space:

$this->table->set_empty("&nbsp;");

$this->table->clear()

Lets you clear the table heading and row data. If you need to show multiple tables with different data you should to call this function after each table has been generated to empty the previous table information. Example:

$this->load->library('table');

$this->table->set_heading('Name', 'Color', 'Size');
$this->table->add_row('Fred', 'Blue', 'Small');
$this->table->add_row('Mary', 'Red', 'Large');
$this->table->add_row('John', 'Green', 'Medium');

echo $this->table->generate();

$this->table->clear();

$this->table->set_heading('Name', 'Day', 'Delivery');
$this->table->add_row('Fred', 'Wednesday', 'Express');
$this->table->add_row('Mary', 'Monday', 'Air');
$this->table->add_row('John', 'Saturday', 'Overnight');

echo $this->table->generate();
\ No newline at end of file -- cgit v1.2.3-24-g4f1b