Welcome Guest, Not a member yet? Register   Sign In
HowTo generate several table using CI Table library ?
#1

[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();
#2

[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-gui...table.html
#3

[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-gui...table.html[/quote]

Thanks a lot !




Theme © iAndrew 2016 - Forum software by © MyBB