[suspicious - maybe spam] SELECT probrem
| From: | Phpu | Date: | Thu, 06 Jan 2005 10:42:15 +0000 |
| Subject: | [suspicious - maybe spam] SELECT probrem | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-205721@lists.php.net to get a copy of this message | ||
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