[eluser]shinokada[/eluser]
I have the following model, control and view.
It returns only one data.
Could anyone point out what I am doing wrong please?
Model
Code:
function getGalleryone(){
$data = array();
$Q = $this->db->get('products');
if ($Q->num_rows() > 0){
foreach ($Q->result_array() as $row){
$data['products'] = $row;
}
}
$Q->free_result();
return $data;
}
Control
Code:
function galleryone(){
$data['title'] = "Gallerie 1";
$data['products'] = $this->MProducts->getGalleryone();
// getGalleryone returns id, name shortdesc thumbnail image class grouping category
$data['main'] = 'galleryone';// this is using views/galleryone.php
$this->load->vars($data);
$this->load->view('template');
}
View
Code:
foreach ($products as $key =>$product)
{
echo "<pre>";
print_r ($product);
echo "</pre>";
}