Welcome Guest, Not a member yet? Register   Sign In
Pagination - Formatting outputted table
#1

[eluser]Medikal[/eluser]
Alright so I've been learning pagination the codeigniter way, and the only way I know to output is:
table->generate, with the get query behind it returning plenty of rows.
It outputs a table with ID, title, text, category, time, rank, etc.

I only way to display title, text, rank, though I need the category and ID for outputting URL's, so I'm curious how I could get this data out...

Current Controller:
Code:
$config['base_url'] = 'http://localhost/beta/index.php/articles';
                $config['total_rows'] = $this->db->get('articles')->num_rows();
                $config['per_page'] = 10;
                $config['num_links'] = 2;                
                
                $this->pagination->initialize($config);
                
                // This limits the per page - offset
                $data['records'] = $this->db->get('articles', $config['per_page'], $this->uri->segment(2));
                
                $data['main_content'] = 'articles_view';
                $this->load->view('includes/template', $data);

Current View:
Code:
<?php

$this->table->set_caption('Main Articles');
$tmpl = array (
                    'table_open'          => '<table border="1" cellpadding="4" cellspacing="0">',

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

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

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

                    'table_close'         => '</table>'
              );
$this->table->set_template($tmpl);
echo $this->table->generate($records);
echo $this->pagination->create_links(); ?&gt;

Thank you.
#2

[eluser]tkyy[/eluser]
in my opinion the codeigniter table generation stuff is too much trouble for what its worth, try creating a view and just running a foreach iteration there with arrays of data passed down from the controller, i find it much easier.




Theme © iAndrew 2016 - Forum software by © MyBB