我试图打印控制器中的阵列,将其传递给一个前视图,这是输出
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] => ) ) )
我得到这个方法在数组中我maincontroller
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