据我所知,我有这段代码在定义数据的地方,这些是我得到的错误:
遇到PHP错误
严重性:通知
消息:未定义的变量:empdata
文件名:views / employee.php
行号:51 **
回溯:
文件:C:\ xampp \ htdocs \ providentfund \ application \ views \ employee.php 线:51 功能:_error_handler
文件: C:\ xampp \ htdocs \ providentfund \ application \ libraries \ BaseController.php 行:99功能:查看
文件: C:\ xampp \ htdocs \ providentfund \ application \ controllers \ Employee.php 行:19功能:loadViews
文件:C:\ xampp \ htdocs \ providentfund \ index.php行:315功能: require_once
控制器:
public function display_all()
{
$result=$this->Employee_model->display_all();
$data['empdata']=$result;
$this->loadViews("employee",$this->global,NULL);
}
型号:
function display_all()
{
$query=$this->db->query("select * from employetbl");
return $query->result();
}
和视图:
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>Rendering engine</th>
<th>Browser</th>
<th>Platform(s)</th>
<th>Engine version</th>
<th>CSS grade</th>
</tr>
</thead>
<tbody>
<?php
$cnt=1;
foreach($empdata as $rec)
{
print_r($empdata);
die();
?>
<tr>
<td><?php echo $rec['fullName'];?></td>
</tr>
<?php
// for serial number increment
$cnt++;
} ?>
为什么会出现错误消息“未定义的变量” ?