php - How do I put an array into an SQL? -


i have following php code getting list of numbers database:

  $current_product_id = "select `product_id`,`category_id` `oc_product_to_category` `product_id`='$product_id' ";      $current_product_ids = mysql_query($current_product_id);     $current_product_cat_ids='';    while($current_product_cat_id = mysql_fetch_array($current_product_ids)){ $current_product_cat_ids.=$current_product_cat_id['category_id'].','; }   echo $current_product_cat_ids; 

the code echos this: 84,109,140,146,151,152,

i take each of numbers , somehow use them in sql query kinda this:

$parent_category_ids = "select `category_id`,`path_id` `oc_category_path` `category_id`='84,109,140,146,151,152'" 

so can put values sql query. ideas how can this? thanks

using in clause , same variable:

$res = mysql_query("select `category_id`,`path_id` `oc_category_path` `category_id` in (" . rtrim($current_product_cat_ids, ',') . ")"); while ($row = mysql_fetch_assoc($res)) {     print_r($row); } 

Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -