2
I’m having a problem retrieving data from two tables, both associated.
When I go in the browser and put the controller and then the method, it comes to me with this message Array()
. Could someone tell me the problem with my code?
public function categoria($slug_categoria = null){
//Recebendo os dados das categorias
$menu_categoria['categorias'] = $this->db->get('categorias')->result();
//Criando querys SQL com JOIN usando o Active Record
$this->db->select('r.id_receita, r.nome, r.slug_receita, r.foto, c.categoria');
$this->db->from('receitas r');
$this->db->join('categorias c', 'c.id_categoria = r.categoria', 'INNER');
$this->db->where('c.slug_categoria', $slug_categoria);
$this->db->order_by('r.nome', 'ASC');
$receita['receitas'] = $this->db->get()->result();
//Carregando as views
$this->load->view('html_header');
$this->load->view('header');
$this->load->view('menu_category', $menu_categoria);
$this->load->view('categoria', $receita);
$this->load->view('footer');
$this->load->view('html_footer');
}
I tried this:
<?php
echo heading("Receitas Deliciosas", 2);
if (count($receitas) > 0) {
?>
<ul>
<?php
echo heading($receitas[0]->categoria, 3);
foreach ($receitas as $item):
?>
<li class="gradiente1 radious">
<?php
echo anchor("receita/" . $item->slug_receita, $item->nome);
?>
</li>
<?php endforeach; ?>
</ul>
<?php
}else {
echo "Nenhuma receita encontrada nesta categoria.";
}
?>
I looped it and it ran echo "No recipes found...".
Manage to solve the problem, thanks for the help
– Andrew Maxwell