CodeIgniter Forums
HowTo generate several table using CI Table library ? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: HowTo generate several table using CI Table library ? (/showthread.php?tid=23683)



HowTo generate several table using CI Table library ? - El Forum - 10-19-2009

[eluser]minoh[/eluser]
Hello guys,

I'm trying to use CI Table library to generate 2 tables elements. the problem is that in the second table i get seconde table data but also first table data.

this is my code :

Code:
// first table
$this->load->library('table');
$this->table->set_empty(' ');
$this->table->set_heading('No','Fourniture','Quantity','Price');
$f = 0 + $offset;

if(isset($_SESSION['fournitures']))
{
   $f_sess = $_SESSION['fournitures'];
  
   foreach($f_sess as $fourniture)
   {
       $this->table->add_row(++$f, fourniture['fourniture'], $fourniture['qt'],
       $fourniture['pr'].' '.'€');
   }
}
$data['fournitures_table'] = $this->table->generate();

// second table
$this->table->set_empty(' ');
$this->table->set_heading('No','Other Fourniture','Quantity','Price');
$of = 0 + $offset;

if(isset($_SESSION['other_fournitures']))
{
   $of_sess = $_SESSION['other_fournitures'];
  
   foreach($of_sess as $other_fourniture)
   {
       $this->table->add_row(++$of, other_fourniture['other_fourniture'], $other_fourniture['qt'], $other_fourniture['pr'].' '.'€');
   }
}
$data['other_fournitures_table'] = $this->table->generate();



HowTo generate several table using CI Table library ? - El Forum - 10-19-2009

[eluser]BrianDHall[/eluser]
You're missing clear():

Quote: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.

From: http://ellislab.com/codeigniter/user-guide/libraries/table.html


HowTo generate several table using CI Table library ? - El Forum - 10-19-2009

[eluser]minoh[/eluser]
[quote author="BrianDHall" date="1255982613"]You're missing clear():

Quote: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.

From: http://ellislab.com/codeigniter/user-guide/libraries/table.html[/quote]

Thanks a lot !