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

what's wrong in my code... please check it again and help me please....
i also used return $qry->row_array();  instead of return $qry.... following is error message

ERROR : Fatal error: Call to a member function result() on a non-object in C:\xampp\htdocs\sms\application\views\HomeView.php on line 12
------------------------------------------
HomeController.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class HomeController extends CI_Controller
{

public function index()
{
$this->load->database();
$this->load->model('select');
$data['cat'] = $this->select->select();
$this->load->view('HomeView', $data);

$msg['top'] = $this->select->topmenu();
$this->load->view('HomeView', $msg);
}
}
?>
-------------------
Select.php(Model)
<?php defined('BASEPATH') OR exit('No direct script access allowed'); ?>
<?php
class Select extends CI_Model  
  {  
     public function select()  
     {  
        //data is retrive from this query  
        $query = $this->db->get_where('categories',array('category_name'=>'English'));
        return $query;  
     }  
 public function topmenu()
 {
  $qry=$this->db->get('categories');
return $qry;
 }
  }  
?>
------------------------------
HomeView.php

<?php
foreach($top->result() 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)
{
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 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