你好朋友我有一个codeigniter问题并使用foreach返回db结果我有这个:
function get_test($id)
{
$this -> db -> select('name, date, title, description');
$this -> db -> from('table1');
$this -> db -> join('table2', 'table1.id = table2.id');
$this -> db -> where('table1.id', $id);
$query = $this -> db -> get();
return $query->row_array();
}
控制器
function index()
{
$session_data = $this->session->userdata('logged_in');
$data['id'] = $session_data['id'];
//SQL
$data['results'] = $this->model1_model->get_test($data['id']);
$this->load->view('base/header');
$this->load->view('incidencia/index',$data);
}
视图
<?php foreach($results as $i): ?>
<div class="panel panel-default">
<div class="panel-heading">
<div class="row">
<div class="col-md-2">
<p><b>Id incidencia:</b> <?php echo $i['id'];?></p>
</div>
<div class="col-md-2">
<p><b>Usuario:</b> <?php echo $i['name']; ?></p>
</div>
</div>
</div>
<div class="panel-body">
<div class="col-md-10">
<p><b></b> <?php echo $i['title]; ?><p>
<p><b></b> <?php echo $i['description']; ?></p>
</div>
<div class="col-md-2">
</div>
</div>
</div>
<?php endforeach; ?>
但我有这个错误:消息:非法字符串偏移'名称