我正在使用CI框架制作计算机实验室监控系统。 我想在列表中显示所选项目的详细信息,但出现错误提示:
消息:试图获取非对象的属性'invent_id'
这是我的代码查看代码
<?php if(!empty($value)): ?>
<?php foreach($value as $post ): ?>
<tr>
<td data-field="id"><?php echo $post->invent_id;?></td>
<td data-field="id"><?php echo $post->name;?></td>
<td data-field="id"><?php echo $post->type;?></td>
<td data-field="id"><?php echo $post->stock;?></td>
<td>
<button name="view" data-toggle="modal" data-target="#exampleModal<?php echo $post->invent_id; ?>" class="btn btn-info view_data"> <span class="glyphicon glyphicon-eye-open">
</span></button>
<a href="#" class="btn btn-success"><span class="glyphicon glyphicon-edit"></span></a>
<a href="#" class="btn btn-danger"><span class="glyphicon glyphicon-ban-circle"></span></a></td>
<?php $this->load->view('Modal/view_inventory_detail', $post); ?>
<?php endforeach; ?>
<?php else: ?>
<tr>
<td>No Records Found</td>
</tr>
<?php endif; ?>
</tr>
</tbody>
</table>
我的控制器
function inventory_list(){
$value['value'] = $this->Admin_Model->get_inventory();
$this->load->view('HeadtoFoot/header');
$this->load->view('Admin/inventory/list',$value);
$this->load->View('HeadtoFoot/footer');
}
我的模态
<div class="modal fade" id="exampleModal<?php echo $post->invent_id; ?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Item Details</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<!-- Details Goes Here -->
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
答案 0 :(得分:0)
在CI中,尝试获取非对象的属性错误通常在运行查询时发生。我猜想错误是在调用模型时发生的:
$this->Admin_Model->get_inventory()