[eluser]Dandy_andy[/eluser]
I have been searching for a simple explanation to my question but can't find one. I have a DB table from which I want to return only a specific field that could apply to various rows. For example:-
ID mem_id photo_path
-- ------ ----------
1 1001 somepath1
2 1002 somepath2
3 1003 somepath3
4 1003 somepath4
5 1003 somepath5
6 1003 somepath6
7 1004 somepath7
8 1005 somepath8
I am just interest in the 'photo_path's that apply for each 'mem_id'.
I have a model set up to extract rows or each instance of a particular MEM_ID:-
Code:
function return_photo_paths($id) {
$this->db->select('photo_path');
$this->db->from('photos');
$this->db->where('mem_id', $id);
$query = $this->db->get();
if ($query->num_rows() > 0) {
$row = $query->result_array();
return $row;
}
}
The problem I have is passing the array through to my controller in the most simplest way so that I can call on each of the paths by using $photo_path[1], $photo_path[2]... but I can't seem to achieve this as the result returned is a multidimensional array.
My controller looks like this at the moment:-
Code:
$photopath = $this->Image_file->return_photo_paths($id);
$per_id['photopath_inview'] = $photopath;
$this->load->view('profile', $per_id);
And in my view, I want to be able to call on the various paths by using a loop as the number will vary depending on which photos are assigned to which user...
Code:
<?php
foreach ($photopath_inview as $value)
{
echo $value;
}
?>
Any help appreciated. Thanks.