我正在做一个项目,该项目需要我在一列中显示所有数据。该表应该是 2 列,向下 7 行,其中一列将包含来自数据库的数据,而其他列将具有要检查的复选框。
我怎样才能制作这样的桌子?我尝试在数组中使用模板,然后加载它:
$this->table->set_template($tmp1);
但它不起作用,它仍然在一行中显示所有内容。
这是我的代码:
视图.php
<body>
<h1>Answer</h1>
<div id="pagination">
<?php echo $this->table->generate($records);?>
<?php echo $this->pagination->create_links(); ?>
控制器.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);
}
}
?>