Reputation: 575
I'm working on a project that requires for me to display all the data in one column. The table should be 2 columns with 7 rows down one column will have data from database and other will have check boxes to be checked.
How can I make a table like this? I tried using template in an array and then load it with:
$this->table->set_template($tmp1);
but it doesn't work, it's still displaying everything in one row.
Here is my code:
view.php
<body>
<h1>Answer</h1>
<div id="pagination">
<?php echo $this->table->generate($records);?>
<?php echo $this->pagination->create_links(); ?>
controller.php
function index()
{
$this->load->library('pagination');
$this->load->library('table');
$config['base_url'] = 'http://localhost/admin/index.php/survey/index';
$config['total_rows'] = $this->db->get('save_survey')->num_rows();
$config['per_page'] = 1;
$config['num_links'] = 10;
$config['full_tag_open'] = '<div id="pagination">';
$config['full_tag_close'] = '</div>';
$this->pagination->initialize($config);
//print_r($this->uri->segment());die;
$data['records'] = $this->db->get('save_survey', $config['per_page'], $this->uri->segment(3, 0))->result_array();
$data['pagination'] = $this->pagination->create_links();
$this->load->view('survey_view', $data);
}
}
?>
Upvotes: 1
Views: 213
Reputation: 708
If you want to create a customized table containing checkboxes
Best way is to generate the table manually you do this by the following
$data['records'] = $this->db->get('save_survay', $config['per_page'], $this->uri->segment(3, 0))->result_array();
foreach($data['records'] as $record)
{
$this->table->add_row(
form_checkbox($data, $value),
$record['col1'],
$record['col2']
)
}
and do not forget to set the headings yourself as well
$this->table->set_heading('h1','h2',...etc)
Upvotes: 1