tbl_products:
+------------+--------------+-------------+------------+
| product_id | product_name | category_id |company_name|
+------------------------------------------------------+
| 1 | iPhone | 3 | Apple |
| 2 | galaxy s1 | 3 | Samsung |
| 3 | galaxy s2 | 3 | Samsung |
| 4 | tab | 4 | Apple |
+------------------------------------------------------+
From the above table, i want to get the company name according to the category_id. I have used foreach to get the value. I got Samsung 2 times and Apple once. But i want Samsung and Apple both will show only once. Is it possible? i wrote the bellow code in my model.
public function select_company_by_category_id($category_id) {
$this->db->select('*');
$this->db->from('tbl_products');
$this->db->where('category_id', $category_id);
$query_result = $this->db->get();
$result = $query_result->result();
return $result;
}