消息:未定义的变量:视图中的信息

时间:2018-03-28 19:25:10

标签: php codeigniter-3

我从CodeIgniter中的数据库中获取数据。数据显示,但此错误也即将到来。

型号:

public function database()
{
    $this->load->database();

    $sql = $this->db->query("SELECT * FROM info");

    $result = $sql->result_array();

    return $result;
}

控制器:

public function home()
{
    $this->load->model('Mymodel');
    $this->Mymodel->result();



    $data['info'] = $this->Mymodel->database();

    $this->load->view('home',$data);
} 

查看:

<?php
$u = 0;

foreach ((array) $info as $inform) {
    $u++; 
    echo '<tr>
              <td>'.$u.'</td>

              <td>'.$inform['u_name'].'</td>
              <td>'.$inform['u_email'].'</td>
              <td>'.$inform['u_phone'].'</td>
              <td>'.$inform['u_comment'].'</td>
              <td>'.$inform['u_date'].'</td>

          </tr>';
}
?>

错误: 遇到PHP错误 严重性:注意

消息:未定义的变量:info

文件名:views / home.php

0 个答案:

没有答案
相关问题