i've got a value that title is brands and such as this :
$brands = "1,2,3,4,5,";
i'm able to convert this value for this :
$brands = "1,2,3,4,5";
i would like write source that choose * from table where id = all of brands
for instance :
select * from brands where (id='1' or id='2' or id='3' or id='4' or id='5');
1,2,3,4,5 is Variable and may transformed for instance can alter to at least one,2,9,4,5,8
the way i can write this ? help thanks
If you have the ids comma delimited...
$query = ' SELECT * FROM `brands` WHERE `id` IN (' . $brands . ')';
In case your ids come from user input and never already made safe, use...
$ids = implode(',', array_map('intval', explode(',', $ids)));
"select * from brands where id in (".$brands.");"