[eluser]underskor[/eluser]
I am retrieving X rows from the DB in a model, and want to refer to the fields of each row. I think the best way to do it is through multidimensional arrays, but I can figure out how to do it.
Code:
$this->db->select('field0, field1, field2, field3, field4');
$this->db->from('table');
$this->db->order_by('field0', 'desc');
$this->db->limit(5);
$query = $this->db->get();
$row_count = $query->num_rows;
for($i=0; $i<=$row_count; $i++)
{
//This is about where I got lost
foreach ($query->result_array() as $row[$i])
{
return $row;
}
}
I want to be able to do the following:
Code:
echo $row[0]['field0'];
echo $row[0]['field1'];
echo $row[0]['field2'];
[..]
echo $row[1]['field0'];
echo $row[1]['field1'];
echo $row[1]['field2'];
[..]
and so on
It's probably something simple, but I've had a read over the documentation and can't see any examples/functions which look to be of any help.
Thanks