I do it this way, for example if I'm going to show the list of products or something like this:
in my index:
public function index()
{
$data = array();
$this->load->model("Modeloproducto");
$this->data["productos"] = $this->Modeloproductos->mostrar();
$this->load->view("paginas/lista_peliculas", $this->data);
}
In my "Product Model" product model
function mostrar(){
$this->db->from("Producto");
$q = $this->db->get();
return $q->result();
}
And in my view:
<table>
<thead>
<tr>Encabezados de la tabla</tr>
</thead>
<tbody>
<?php
foreach ($productos as $producto) {
echo "<td>$producto->nombre</td>
<td>$producto->descripcion</td>
<td>
<img src=\" " . base_url() . "/imagen/miniatura/$producto->imagen \">
</td>
";
}
</tbody>
</table>
If it works for you, mark my answer as the correct one.