• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HTML Table class?

#11
[eluser]InsiteFX[/eluser]
Code:
// This sets up a table template.
$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 class="alt">',
    'row_alt_end'         => '</tr>',
    'cell_alt_start'      => '<td>',
    'cell_alt_end'        => '</td>',

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

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

// Adding heading and rows to table.
$data = array(
    array('Name', 'Color', 'Size'),
    array('Fred', 'Blue', 'Small'),
    array('Mary', 'Red', 'Large'),
    array('John', 'Green', 'Medium')
);

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

CodeIgniter HTML Table

InsiteFX

#12
[eluser]tonanbarbarian[/eluser]
what i suspect is happening is that the table class is caching the output
so that the first time it displays the table
the second time it display the table again but this time the data in the table is the original copy of the data plus the new copy of the data

that is sort of born out by the way you show the output was created on the link you gave
you had the following
title row 'Name', 'Color', 'Size'
normal row 'Fred', 'Blue', 'Small'
normal row 'Mary', 'Red', 'Large'
normal row 'John', 'Green', 'Medium'
title row 'Name', 'Color', 'Size'
normal row 'Fred', 'Blue', 'Small'
normal row 'Mary', 'Red', 'Large'
normal row 'John', 'Green', 'Medium'
normal 'Name', 'Color', 'Size'
normal row 'Fred', 'Blue', 'Small'
normal row 'Mary', 'Red', 'Large'
normal row 'John', 'Green', 'Medium'

so the first 4 rows of the table, one title row and 3 data rows was the call made in the constructor
then the next 8 rows, one title row and 7 normal rows, was the concatenated data in the second run

the table code by default makes the first row of data a title row and all the rest as normal rows

#13
[eluser]anna16[/eluser]
@tonanbarbarian

thanks for the explanation.

Actually i wanted to incorporate the codes made by insiteFX
can you teach me how do i incorporate insiteFX table codes with the output data?

Thanks again in advanced.

#14
[eluser]tonanbarbarian[/eluser]
now that you have removed the extra call to the sample1 method the code insiteFX has provided should run fine

#15
[eluser]InsiteFX[/eluser]
If you need to change the table data you need to do this!
Code:
$this->table->clear();

Then reload your table data array.

InsiteFX


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.