我在获取数据时遇到问题,因为它给出了错误。并且还显示另一个错误
严重性:注意 消息:试图获取非对象的属性 文件名:views / view_school.php 行号:121
请帮助我,我是Codeignitor的新手。...
严重性:注意 消息:未定义的属性:mysqli :: $ firstname 文件名:views / view_school.php 行号:121
回溯:
**这是我的控制器代码**
public function index($offset = 0)
{
$data['_pagecontent']="view_school";
/*$data['sidebar']="schoolview";*/
$limit = 10;
$result = $this->AllSchoolModel->get_school($limit, $offset);
$data['schools'] = $result['rows'];
$data['num_results'] = $result['num_rows'];
// load pagination library
$this->load->library('pagination');
$config = array();
$config['base_url'] = site_url("AllSchool/index");
$config['total_rows'] = $data['num_results'];
$config['per_page'] = $limit;
//which uri segment indicates pagination number
$config['uri_segment'] = 3;
$config['use_page_numbers'] = TRUE;
//max links on a page will be shown
$config['num_links'] = 5;
$config['full_tag_open'] = '<ul class="pagination">';
$config['full_tag_close'] = '</ul>';
$config['num_tag_open'] = '<li class="page-item">';
$config['num_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li class="page-item active"><a class="page-link" href="#">';
$config['cur_tag_close'] = '</a></li>';
$config['next_tag_open'] = '<li class="page-item">';
$config['next_tagl_close'] = '</a></li>';
$config['prev_tag_open'] = '<li class="page-item">';
$config['prev_tagl_close'] = '</li>';
$config['first_tag_open'] = '<li class="page-item disabled">';
$config['first_tagl_close'] = '</li>';
$config['last_tag_open'] = '<li class="page-item">';
$config['last_tagl_close'] = '</a></li>';
$config['attributes'] = array('class' => 'page-link');
$this->pagination->initialize($config);
$data['links'] = $this->pagination->create_links();
$this->load->view('MainContent',$data);
}
这是我的模型代码
private $blogs = 'userregistration';
function get_school($limit, $offset)
{
if ($offset > 0) {
$offset = ($offset - 1) * $limit;
}
$result['rows'] = $this->db->get($this->blogs, $limit, $offset);
$result['num_rows'] = $this->db->count_all_results($this->blogs);
return $result;
}
这是我的观点
<table class="table datatable-basic">
<thead>
<tr>
<th>First Name</th>
</tr>
</thead>
<tbody>
<?php
if( !empty($schools) ) {
foreach($schools as $rowss)
{
?>
<tr>
<td><?php echo $rowss->firstname;?></td>
</tr>
<?php
}
}
?>
</tbody>
</table>