[英]How to use table class of codeigniter
Is any trick to add edit/delete link in each row 在每行中添加编辑/删除链接有什么技巧吗
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
代码错误:无法在第8行的C:\\ xampp \\ htdocs \\ CodeIgniter-3.0.6 \\ application \\ views \\ admin.php中将mysqli类型的对象用作数组
<?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();
?>
query()
doesn't return an array with the objects of desire directly, but an mysqli_result
object instead; query()
不会直接返回具有所需对象的数组,而是会mysqli_result
对象。 hence you cannot use it as such. 因此,您不能原样使用它。
What you probably want to do is 您可能想做的是
while ($row = $new->fetch_assoc()) {
// ...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.