Jump to content

Recommended Posts

Hi folks,

I need some help with taking vars from array to the DB.

 

my array something like this:

Array ( [0] => 137 [1] => 800 [2] => 732 [3] => 198) 

 

The Array contains IDs of products in database.

 

I want to do something like this first:

 

$db->Query("SELECT catID FROM `products` WHERE `id` = '$VAROFARRAY'");

 

That the DB Query will loop the whole array variables.

 

And then:

$db->Query("SELECT `name` FROM `categories` WHERE `id= '$catID'");

 

I a little bit complicated with it..

 

thanks..

Link to comment
https://forums.phpfreaks.com/topic/265882-from-array-to-sql-query/
Share on other sites

thanks,

but maybe you didn't get me.

I have already the array of my products.

All I have to is to loop it on the query of categories to get the name.

 

Array => 1,3,5,7,8 (The ID's of the products)

 

and I want something like:

 

forearch($array as pID) ...
while($row = $db->Query("SELECT FROM `cats` WHERE `id` = '{$pID}'") ..

 

Something liike that..

 

thank you very much...

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.