无法显示来自控制器的数据

cant display the data from controller

我的问题是我无法在数据库中获取数据,但是如果我使用 var_dump() 我有数据。这是错误:

A PHP Error was encountered Severity: Notice Message: Undefined index: projectid Filename: views/accounting_status.php Line Number: 46

这是我的观点

此页面访问错误。

<div class="well">
<p><h1><?=$p['projectid']?></h1></p>
<p><?=$p['code']?></p></div>

这是我的控制器

function id($projectid){
    $data['p'] = $this->Accounting_Model->get_awardedid($projectid);
    //echo "<pre>".print_r($data)."</pre>";
    $this->load->view('tmp_header');
    $this->load->view('accounting_status',$data);
}

这是我的模特

function get_awardedid($projectid){
    $this->db->select('*')->from('projects')
                          ->join('customer', 'projects.customerid = customer.customerid')
                          ->join('employees', 'projects.endorse_by = employees.employeeid')
                          ->where(array('acctg'=>1,'projectid'=>$projectid))
                          ->order_by('datecreated', 'desc');
    $query = $this->db->get();
    return $query->result_array();
}

如果结果将是单行,则按如下方式更改模型:

function get_awardedid($projectid){
    $this->db->select('*')->from('projects')
                          ->join('customer', 'projects.customerid = customer.customerid')
                          ->join('employees', 'projects.endorse_by = employees.employeeid')
                          ->where(array('acctg'=>1,'projectid'=>$projectid))
                          ->order_by('datecreated', 'desc');
    $query = $this->db->get();
    return $query->row_array();
}

如果结果是多条记录,则使用for循环打印视图中的值。

<div class="well">foreach($p as $value){<p><h1><?=$value['projectid']?></h1></p><p><?=$value['code']?></p>}</div>