【发布时间】:2017-06-21 15:52:09
【问题描述】:
我尝试按照site 上的教程通过 Code Igniter 从 DB 中查看我的记录,但它显示了错误消息
我可以尝试什么来识别它?
以下是查看“view_inlist.php”代码
<table class="table table-striped table-bordered">
<tr>
<td><strong>ID</strong></td>
<td><strong>Name</strong></td>
<td><strong>Number</strong></td>
<td><strong>Type</strong></td>
<td><strong>Unit</strong></td>
<td><strong>Date</strong></td>
</tr>
<?php foreach($LIST as $list)
{?>
<tr>
<td><?=$list->ID;?></td>
<td><?=$list->Name;?></td>
<td><?=$list->Letter_Number;?></td>
<td><?=$list->Letter_Type;?></td>
<td><?=$list->Unit;?></td>
<td><?=$list->Date;?></td>
</tr>
<?php }?>
</table>
这里是控制器“Main.php”
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Main extends CI_Controller {
public function check_inList() {
$this->load->model('login');
$query = $this->login->check_inlist();
$data['LIST'] = null;
if($query){
$data['LIST'] = $query;
}
$this->load->view('form/view_inlist', $data);
}
}
这里是模型“login.php”
function check_inlist(){
$this->db->select("ID,Name,Letter_Number,Letter_Type,Unit,Date");
$this->db->from('in_list');
$query = $this->db->get();
return $query->result();
}
【问题讨论】:
-
您在 check_inList() 操作中遇到错误吗?
-
它无法识别视图中的 $LIST。不知道是怎么互相交流的。 @B.Desai
-
我在问你“你什么时候会收到这个错误?”给你的网址示例
-
打印控制器中$query的值,即print_r($query);退出;
-
我想你忘了在控制器 Main.php 中加载模型。要在控制器中加载模型,只需编写 $this->load->model('login');
标签: php html mysql twitter-bootstrap codeigniter