1
添加行似乎很容易,但我想添加列到我的數據中有複選框,以便您可以「編輯」或「刪除」該行。使用CodeIgniter HTML Table Class,我如何添加額外的列?
任何CI友好的方式來做到這一點?
添加行似乎很容易,但我想添加列到我的數據中有複選框,以便您可以「編輯」或「刪除」該行。使用CodeIgniter HTML Table Class,我如何添加額外的列?
任何CI友好的方式來做到這一點?
手動設置你的標題和列插入無論你在像這樣最後一列需要...
$this->table->set_heading('Heading One', 'Heading Two', ... , 'Links'); //set your headings
foreach($data_rows as $row) { //set your rows here
// first build links for this row assuming you need the urls to
// look like 'http://domain/index.php/controller/{action}/{id}
$links = anchor('controller/edit/'.$row->id ,'Edit');
$links .= anchor('controller/delete/'.$row->id , 'Delete');
$this->table->add_row(
$row->heading_one,
$row->heading_two,
...,
$links, //add the links you created to the last row, corresponding to your 'Links' Header
);
}
echo $this->table->generate();
**Error in code : Cannot use object of type mysqli as array in
C:\xampp\htdocs\CodeIgniter-3.0.6\application\views\admin.php on line 8**
<?php
$table_property = array('table_open' => '<table cellpadding="2" cellspacing="1" class="table table-hover">');
$this->table->set_heading('#Id','Username','Password','Name','Edit','Delete');
$this->table->set_template($table_property);
$new=$this->db->query("select * from tbl_admin");
foreach($new as $row) {
$links = anchor('admin/edit/'.$row['User_ID'] ,'Edit');
$links .= anchor('admin/delete/'.$row['User_ID'] , 'Delete');
$this->table->add_row(
$row->User_ID,
$row->Username,
$row->Password,
$row->Full_Name,
$links
);
}
echo $this->table->generate();
?>
你能解釋一下你的代碼? (添加一些文字到你的答案)這個代碼如何解決OP問題?代碼做了什麼? – Athafoud 2016-06-30 10:58:26