Hi,

I have an array, for ex: $products=array(1, 2,  5 , 7)

I want to select all products from the database that has the ids of products.
I use this but doesn't work:

$sql = '';
foreach($products AS $products_id){
if(strlen($sql)){ $sql .= ' OR '; }
$sql .= "product_id = '$products_id'";
}
      
$sql2 = "SELECT product_name FROM accessories WHERE " .$sql;

Please help me !!!!

Thanks

Reply via email to