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

hi everyone

i am new in codeigniter. please help me.

i am unable to fetch the records from database.

my HomeController file is following...


<?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);

$this->load->database();
$this->load->model('select');
$msg['menu'] = $this->select->topmenu();
$this->load->view('HomeView', $msg);

}

}
----------model----------------
select.php

<?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;
}
}

?>
-----------Home_view.php--------------------

<?php
foreach($menu->result() as $m)
{
echo "<div class='panel-body'><a href='#'>". $m->category_name ."</a></div>";
}
$menu->free_result();
?>

<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