Welcome Guest, Not a member yet? Register   Sign In
Links For ID's Table Helper and Pagination
#1

[eluser]elusid[/eluser]
I'm making a standard CRUD system while toying with CodeIgniter trying to learn the ropes....


Here is my problem.

I want to do pagination on a database query. I've got pagination working and its displaying the correct data in my 'view' using the table helper. The problem is that I would like to add links to ID's within my table. Can I change how the data is being displayed within the table and turn my ID's column into links?

here is my code:

The controler
Code:
function index() {
    //checks if user is logged in
        if ($this->session->userdata('logged_in') != TRUE) {
            redirect('login');
        }

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

        $config['base_url'] = base_url().'admin/index';
    $config['total_rows'] = $this->db->get('uploads')->num_rows();
    $config['per_page'] = 5;
    $config['num_links'] = 20;
    $config['full_tag_open'] = '<div id="pagination">';
    $config['full_tag_close'] = '</div>';

    $this->pagination->initialize($config);

$query = $this->db->get('uploads', $config['per_page'], $this->uri->segment(3));
$data['records'] = $query->result_array();

$this->load->view('admin_view', $data);
}

my view
Code:
<div style="padding:10px 10px 10px 10px;">

    &lt;?php $this->table->set_heading('ID','File Name', 'Location');?&gt;
    &lt;?php echo $this->table->generate($records); ?&gt;


?&gt;
    &lt;?php echo $this->pagination->create_links(); ?&gt;

Thanks ahead for any help i'm in love with CodeIgniter its been a fun learning process.
#2

[eluser]doob[/eluser]
Try
Code:
&lt;?php
$this->table->set_heading('ID','File Name', 'Location');

foreach($records as $row) :

    $this->table->add_row(
        $row['id'],
        $row['filename'],
        $row['location']
    );

endfor;

echo $this->table->generate();

?&gt;




Theme © iAndrew 2016 - Forum software by © MyBB