【发布时间】:2017-06-08 10:53:51
【问题描述】:
遇到 PHP 错误 严重性:通知
消息:未定义变量:结果
文件名:用户/messages.php
行号:87
回溯:
文件:E:\xampp\htdocs\ci\application\views\user\messages.php 行:87 函数:_error_handler
文件:E:\xampp\htdocs\ci\application\controllers\users\Dashboard.php 行:12 功能:查看
文件:E:\xampp\htdocs\ci\index.php 行:315 功能:require_once
这是我的代码 控制器
<?php defined('BASEPATH') OR exit('No direct script access allowed');
class Bills extends CI_Controller{
function __construct(){
parent::__construct();
}
public function bill(){
$id = $this->session->userdata('email');
$this->load->database();
$this->load->helper(array('form', 'url', 'html'));
$this->load->model('fuser/Bill');
$data['result'] = $this->Bill->bills();
$this->load->view('user/messages',$data);
}
}
?>
**Model**
<?php
class Bill extends CI_Model
{
function __construct()
{
// Call the Model constructor
parent::__construct();
}
//we will use the select function
public function bills($id)
{
//data is retrive from this query
$query = $this->db->get('invoices');
return $query->result();
}
}
?>
**View**
<div class="billing_tabs_text_part">
<?php foreach($result as $row){?>
<p><?php echo $row['book_id']; }?></p>
</div>
【问题讨论】:
-
我没有得到你的答案
-
在你的 bill() 函数中给你
var_dump($data['result'])什么? -
也从
public function bills($id){中删除id -
@gopal 从 bills () 中删除了 $id 仍然不一样的错误
标签: php codeigniter