在每一行中添加编辑/删除链接是否有任何技巧
代码错误:无法使用mysqli类型的对象作为数组 第8行的C:\ xampp \ htdocs \ CodeIgniter-3.0.6 \ application \ views \ admin.php
<?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();
?>
答案 0 :(得分:0)
query()
不会直接返回包含欲望对象的数组,而是返回mysqli_result
个对象;因此你不能这样使用它。
您可能想要做的是
while ($row = $new->fetch_assoc()) {
// ...
}