I am trying to print selected product names from my database, however all i see is the word "Array" instead of the product name. It is displayed as many times as the number products it finds, and that number is correct, but it only shows "Array"...
Here's my code:
public function lookup($product)
{
$camera = $this->db->query("SELECT name FROM products WHERE type = 'Camera' ");
$laptop = $this->db->query("SELECT name FROM products WHERE type = 'Laptop' ");
$data = array();
switch($product)
{
case 'camera' :
foreach ($camera->result() as $row)
{
$entry = array();
$entry['name'] = $row->name;
$data[] = $entry;
}
return $data; break;
case 'laptop' :
foreach ($laptop->result() as $row)
{
$entry = array();
$entry['name'] = $row->name;
$data[] = $entry;
}
return $data; break;
}
}