[eluser]Isuru[/eluser]
I am new to CodeIgniter and trying to figure out this for hours, but still no success.
Is there anything wrong in the following Model code.
Code:
function getMainFeature(){
$data = array();
$this->db->select(“id,name,shortdesc,image”);
$this->db->where(‘featured’,’true’);
$this->db->where(‘status’, ‘active’);
$this->db->orderby(“rand()”);
$this->db->limit(1);
$Q = $this->db->get(‘products’);
if ($Q->num_rows() > 0){
foreach ($Q->result_array() as $row){
$data = array(
“id” => $row[‘id’],
“name” => $row[‘name’],
“shortdesc” => $row[‘shortdesc’],
“image” => $row[‘image’]
);
}
}
$Q->free_result();
return $data;
}
Or is it in my controller?
Code:
function index(){
$data[‘title’] = “Welcome to Claudia’s Kids”;
$data[‘navlist’] = $this->MCats->getCategoriesNav();
$data[‘mainf’] = $this->MProducts->getMainFeature();
$skip = $data[‘mainf’][‘id’];
$data[‘sidef’] = $this->MProducts->getRandomProducts(3,$skip);
$data[‘main’] = ‘home’;
$this->load->vars($data);
$this->load->view(‘template’);
}
I am learning CodeIgniter... So please be king enough to help! Thanks!