get multiple rows

Posted on 16th Feb 2014 by admin

Hi I want to get multiple rows from a db

I am using this for the db query
Code: public function getCeleb($product_id) {

$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_celeb WHERE product_id = '" . (int)$product_id . "'");


foreach ($query->rows as $result) {
$celeb_id = $result['celeb_id'];
}

return $celeb_id;
}
and this to display the returned data

Code: 'celeb_id' => $result['celeb_id']
print_r ($celeb_id);

the problem is i only get one result from the database and i have multiple entries with the same id

thanks in advance

Other forums