I have 1 mysql table called colors with rows id and name
1 - yellow
2 - black
3 - red
4 - green
5 - white
6 - bl
Try this
$colors = "blue,red,white";
// Exploding string to array
$colors = explode($colors, ',');
$colors_list = array();
foreach($colors as &$color)
{
// Escaping every element
$colors_list[] = "'".mysql_real_escape_string($color)."'";
}
// Executing the query
$query = mysql_query('SELECT `id` FROM `colors` WHERE `name` IN ('.implode(', ', $colors_list).')');
http://php.net/manual/en/function.explode.php
http://php.net/manual/en/function.implode.php