Welcome Guest, Not a member yet? Register   Sign In
how to remove the extra column from the table
#1

[eluser]rajneeshgobin[/eluser]
originally i had this piece of code
Code:
$heading = array('No','usergroup', 'platform', 'reference','id');    

  $CI->table->set_heading($heading);
  $i = 0 + $offset;
  foreach ($parents as $parent){  
   $CI->table->add_row(++$i, $parent->usergroup, $parent->platform, $parent->reference,$parent->id);
  }
  
  //print_r($my_row);
  $data['table'] = $CI->table->generate();

to make it a little mode dynamic i converted it to

Code:
$myArray=array('usergroup', 'platform', 'reference','id');
$tempArray = $myArray;
  array_unshift($tempArray, 'No');
  //$heading = array('No','usergroup', 'platform', 'reference','id'); <---- to make it like this i use unshift    
  $heading = $tempArray ;  
  
  $CI->table->set_heading($heading);
  $i = 0 + $offset;  
  $toArrayparents = (array) $parents;
  foreach ($toArrayparents as $parent) {
  $toArraysingleParent = (array) $parent;
  $my_row['No'] = ++$i;
  foreach($myArray as $val) {

   $my_row[$val]    = $toArraysingleParent[$val];
  
   }
   //$CI->table->add_row(++$i, $book['usergroup'], $book['platform'], $book['reference'],$book['id']);
  
   $CI->table->add_row($my_row);
  }
  //print_r($my_row);
  $data['table'] = $CI->table->generate();

now the problem is
i have a blank column at the begining and an extra column in the table going out of the header
#2

[eluser]rajneeshgobin[/eluser]
i just noticed that if i replace

$my_row['No'] = ++$i;

by

$my_row[0] = ++$i;

the display is ok, any idea where the bug is coming from?
#3

[eluser]InsiteFX[/eluser]
Code:
$my_row[] = ++$i;




Theme © iAndrew 2016 - Forum software by © MyBB