Jump to content

from array to SQL Query


Alechko

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...

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.