[eluser]d1a8lo24[/eluser]
I'm not sure how you want your result but the following will return an array
This is what I do when I get a result know that everyone is different, I just found many uses for doing this.
Code:
function get_allcities()
{
$query = $this->db->distinct()->group_by('city_name')->get('cities');
if ($query->num_rows() > 0)
{
foreach($query->result() as $city)
{
// Reason for doing this is that i can also add item to my result
$city->my_result = 'some result or thing etc...';
$cities[] = $city;
}
return $cities;
}
// else you can ruturn an array or false
return FALSE;
}
Now on your view just do a foreach loop to get the results.
You can also use any array function to split, re arrange and so on for your output is all up to you what you do with your filter cities. or in this case unique cities.