Welcome Guest, Not a member yet? Register   Sign In
Table generation in helper
#1

[eluser]jakeone[/eluser]
Can someone point out my mistake.

I moved some common code to a helper...

Code:
function displaySearchResults($data)
{
  $CI =@ get_instance();
  $CI->table->set_heading('Case Ref','Title','Postcode');
        
  $count = count($data);
  if ($count>0)
  {
    for ($i=0; $i<$count; $i++)
    {
      $CI->table->add_row(array($data[$i]['ref'],$data[$i]['title'], $data[$i]['postcode']));
    }
    $data['resultsTable'] = $CI->table->generate();
    return $data['resultsTable'];
  }
}

$data is a multi-dimensional array. When I run the code, the table is not generated but there is no error. (I can see the data is there with print_r so I assume it must have something to do with the table generation). I am autoloading the table library.

What am I doing wrong? And where would be the best place to call "table->clear"?

Thanks
#2

[eluser]sophistry[/eluser]
pretty sure you need an ampersand and not the "at" sign in the first line of the function.




Theme © iAndrew 2016 - Forum software by © MyBB