Welcome Guest, Not a member yet? Register   Sign In
display data in colums
#4

[eluser]John_Betong_002[/eluser]
Try this:

Code:
$this->load->library('table');
  
  $sql    = 'SELECT id, title FROM your_table_name LIMIT 0,3';
  $query  = $this->db->query($sql);
  
  $data   = array();
  $data[] = array('id', 'title');
  foreach($query->result_array() as $row):
    $data[] = $row;
  endforeach;            

  $tmpl = array
  (
    'table_open'          => '<table style="border:double 4px #333;width:20em;text-align:center">',

    'heading_row_start'   => '<tr style="width:10em;color: red">',
    'heading_row_end'     => '</tr>',
    'heading_cell_start'  => '<th style="width:10em;color: cyan">',
    'heading_cell_end'    => '</th>',

    'row_start'           => '<tr style="width:10em;color:yellow">',
    'row_end'             => '</tr>',
    
    'cell_start'          => '<td style="width:10em;color:green">',
    'cell_end'            => '</td>',

    'row_alt_start'       => '<tr style="width:10em;color:blue">',
    'row_alt_end'         => '</tr>',
    
    'cell_alt_start'      => '<td style="width:10em;color:orange">',
    'cell_alt_end'        => '</td>',

    'table_close'         => '</table>'
  );
  
  $this->table->set_template($tmpl);
  echo $this->table->generate($data);
  die(QW);
&nbsp;
&nbsp;
I forgot to mention - Welcome to the forum...

...and to prevent some posters getting upset

1. please post in the correct forum

2. please learn how to enclose your code inside the code tags Smile
&nbsp;
&nbsp;


Messages In This Thread
display data in colums - by El Forum - 08-05-2011, 10:29 AM
display data in colums - by El Forum - 08-05-2011, 08:06 PM
display data in colums - by El Forum - 08-07-2011, 08:30 PM
display data in colums - by El Forum - 08-07-2011, 09:08 PM
display data in colums - by El Forum - 08-08-2011, 05:29 AM



Theme © iAndrew 2016 - Forum software by © MyBB