Welcome Guest, Not a member yet? Register   Sign In
unable to get data through result()
#6

(This post was last modified: 09-06-2015, 08:03 AM by pdthinh.)

In your model:
Quote:class Select extends CI_Model  
  {  
     public function select()  
     {  
        //data is retrive from this query  
        $query = $this->db->get_where('categories',array('category_name'=>'English')); 
        // you should return result() if the result contain multi rows, or row() if you want only one row.
        return $query->result();
     }  
 public function topmenu()
 {
  $qry=$this->db->get('categories');
return $qry->result();
 }
  }  
?>

In your view:
Quote:<?php 
//foreach($top->result() as $m)
foreach($top as $m)

echo "<div class='panel-body'><a href='#'>". $m->category_name ."</a></div>";
}
?>

<div class="panel-heading">CATEGORIES</div>
<?php 
//foreach($cat->result() as $c)
foreach($cat as $c)
{
echo "<div class='panel-body'><a href='#'>". $c->subcategory_name."</a></div>";
}
?>
</div>
Reply


Messages In This Thread
unable to get data through result() - by nady - 09-05-2015, 11:15 PM
RE: unable to get data through result() - by nady - 09-06-2015, 07:36 AM
RE: unable to get data through result() - by pdthinh - 09-06-2015, 08:02 AM
RE: unable to get data through result() - by nady - 09-06-2015, 11:18 AM
RE: unable to get data through result() - by nady - 09-06-2015, 11:48 AM



Theme © iAndrew 2016 - Forum software by © MyBB