遇到 PHP 错误
严重性:警告
消息:为 foreach() 提供的参数无效
文件名:views/content_view.php
行号:8
模型:
<?php
if ( ! defined('BASEPATH')) exit ('No direct script access allowed');
class Mat_model extends CI_Model
{
public function get_mat()
{
$query = $this->db->get('materials');
$query->result_array();
}
}
?>
看法:
<div id="breadcrumb"><a href="">Home</a> » <a href="">Somewhere</a></div>
<div id="right">
<h1>Lorem Ipsum Dolor Set Amir</h1>
<span class="postinfo"> Posted by <a href="">Dylan</a> on 07.09.06</span>
<p>Lorem ipsum dolor set amir tolos and tacos for plenty to see. jack is the orange sub marine, by any means I found my plans. </p>
<hr />
<h1>
<?php foreach ($news as $one):?>
<?if(is_empty($one))?>
<?=$one['author']?>
<?php endforeach; ?>
</h1>
<span class="postinfo"> Posted by <a href="">Dylan</a> on 07.09.06</span>
<p>Lorem ipsum dolor set amir <a href="">tolos</a> and tacos for plenty to see. jack is the orange sub marine, by any means I found my plans. </p>
</div>
</div>
控制器:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Welcome extends CI_Controller {
public function index()
{
$this->load->view('header_view');
$this->load->view('menu_view');
$this->load->view('categories_view');
$this->load->view('useful_sites_view');
$this->load->model('mat_model');
$data = array();
$data['news'] = $this->mat_model->get_mat();
$this->load->view('content_view',$data);
$this->load->view('footer_view');
}
}
?>
那么我的错误在哪里?我找不到它。