get multiple rows


Posted on 16th Feb 2014 07:03 pm 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) {
Did you know?Explore Trending and Topic pages for more stories like this.

$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
No comments posted yet

Your Answer:

Login to answer
268 Like 12 Dislike
Previous forums Next forums
Other forums

undefined offset help
Hi All,

I kept getting undefined offset PHP notice for a simple for loop. For eg
$va = arr

Any meaningful project for a new C++ programmer?
I want to do some meaningful program, so I can help myself to learn

Assume I know the fol

Getting Resource id #11 while trying to connect..
So i tried using "DEFINE" for the first time and im using the variables i defined to conne

Session
I am having a little trouble with a session. Not sure if it is my browser or what. I know I do not

form variables from database help.
Hi all,

I would like to have a form that gives you options based on the results of an mysql q

help understanding hidden input w/ php
hello i'm doing a tutorial where there are multiple forms for an edit page for a user to update thei

Error in query: Resource id #4??
hey guys, having a minor (i think) problem here that i havent been able to figure out. long story sh

Problem with Subscreen
Dear Experts ,
I am facing a problem with the subscreens. My senario is as follows :

how to export excel file in same server
My first post - php newbie, so appreciate your support.

I'm currently using headers to save w

Echoing a Variable from a Object
How do I get a variable from the new User Class to echo out in this clasS?

class MyApp
{

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash