我尝试在控制器中打印数组,然后将其传递给视图,这是输出
Array ( [annunci] => Array ( [0] => stdClass Object ( [EmailDatore] => you@welcom.it [Nome] => asdasd [Cognome] => asdas [IdAnnuncio] => 9 [Titolo] => sfsdfdsfshrea [Testo] => agrefdgdagdfg [Categoria] => [Sede] => [TipoContratto] => [Add_Date] => [Drop_Date] => )
[1] => stdClass Object ( [EmailDatore] => you@welcom.it [Nome] => asdasd [Cognome] => asdas [IdAnnuncio] => 10 [Titolo] => fafa [Testo] => fafaerea asdasdas dafasfd [Categoria] => [Sede] => [TipoContratto] => [Add_Date] => [Drop_Date] => ) ) )
我在我的主控制器中从此方法获取数组
public function get_annunci(){
$query=$this->user_model->annunci($this->email);
print_r($query);
}
我想将此数组传递给视图,然后读取数据。所以我像这样重写我的方法
public function get_annunci(){
$query=$this->user_model->annunci($this->email);
$this->load->view('main_view',$query);
}
在主视图中我有这个
<div class="tab-pane active" id="annunci">
<ul>
<?php
print_r($annunci);
?>
</ul>
</div>
这是我的错误
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: annunci
Filename: views/tab_annunci_view.php
Line Number: 4