codeigniter - Passing array from controller to view and show it -


i new codeigniter.i want send array controller view , show it.but error show in view:

a php error encountered    severity:notice   message:undefined variable:pub    filename:views/first.php   line number:25      

this code :
cotroller

$data['pub']=$this->mymodel->get_public(); $this->load->view('first',$data); 

model

function pub_article()    {         $where=array('public'=>'1');          $query=$this->db->get_where('article',$where);         if($query->num_rows() > 0)            return $query->result();         else           return false;    } 

view

foreach($pub->result() $row){ echo "<p>".$row->tiltl."</p>" } 

try code:

in model:

$where=array('public'=>'1'); $query=$this->db->get_where('article',$where); if($query->num_rows() > 0)    return $query; else    return false; 

in view:

if($pub!=false) {   foreach($pub->result() $row){    echo "<p>".$row->tiltl."</p>"   } } 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -