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) {

$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

Creating a custom API
I'm creating a site, and I need to create a basic API. Unfortunately I have no idea where to start.

Polymorphism
Was wondering if someone could explain this a little better to me. I had always assumed that it had

Form errors in an array
I'm processing a form and putting the errors in an array. empty($errors) doesn't seem to do the tric

upload photo limits
ive got a upload photo script and im just trying to make more secure currently it limits size and as

Confusing Functions
So, I've been reading up on Functions and I like them! However, I need some help using variables in

Help? Need help on project with templates involving mysql and php.
I'm having a hard time explaining what I want but basically here is what I have in place:

-Da

Request-URI Too Large
I have created a simple submit form for a mysql database that puts a piece of code into database.<

Login logout link help
Hi all,

Im new to php and Im having trouble creating a login/logout link for my page that dis

Multi language - seo links
Im trying to figure out the best method to have a multi language website that will function with seo

string to currency format
Hi guys...

Actually I chunk out some data from txtfile and one of the data contains amount va

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