Welcome Guest, Not a member yet? Register   Sign In
active record with column name spaces
#6

[eluser]InsiteFX[/eluser]
Here is how it is done using a Table Template:
Code:
class MY_Controller extends CI_Controller {

/**
  * -----------------------------------------------------------------------
  * Class variables - public, private, protected and static.
  * -----------------------------------------------------------------------
  */


  // ----------------------------------------------------------------------

/**
  *  __construct
  *
  * Class Constructor PHP 5+
  *
  * @author Raymond King Sr.
  * @access public
  * @return void
  */
  public function __construct()
  {
   parent::__construct();

  $this->load->library('table');

  $tmpl = array (
   'table_open'   => '<table border="0" cellpadding="4" cellspacing="0">',

   'thead_open'   => '<thead>',
   'thead_close'   => '</thead>',

   'heading_row_start'  => '<tr>',
   'heading_row_end'  => '</tr>',
   'heading_cell_start' => '<th>',
   'heading_cell_end'  => '</th>',

   'tbody_open'   => '<tbody>',
   'tbody_close'   => '</tbody>',

   'row_start'    => '<tr>',
   'row_end'    => '</tr>',
   'cell_start'   => '<td>',
   'cell_end'    => '</td>',

   'row_alt_start'   => '<tr class="alt">',
   'row_alt_end'   => '</tr>',
   'cell_alt_start'  => '<td>',
   'cell_alt_end'   => '</td>',

   'table_close'   => '</table>'
  );

  $this->table->set_template($tmpl);
}

}

Now you can use add_row etc and build your table using a foreach loop on your query from the database.

In your view were you want the table generated just add this:
Code:
&lt;?php echo $this->table->generate(); ?&gt;


Messages In This Thread
active record with column name spaces - by El Forum - 04-02-2012, 10:01 PM
active record with column name spaces - by El Forum - 04-02-2012, 11:22 PM
active record with column name spaces - by El Forum - 04-02-2012, 11:56 PM
active record with column name spaces - by El Forum - 04-03-2012, 02:57 AM
active record with column name spaces - by El Forum - 04-03-2012, 03:12 AM
active record with column name spaces - by El Forum - 04-03-2012, 03:22 AM



Theme © iAndrew 2016 - Forum software by © MyBB