php - Mysql_query for all items inside array -


i have array() in php. want search through mysql database simultaneously array items.
example cars array below:

$cars=array("volvo","bmw","toyota"); 

besides array size variable. need search inside mysql database , see if specific row contains array values or not?

something this:

mysql_query("select * person personcar contains $cars[0] , $cars[1] , $cars[2]);  

personcar string. example "volvo, bmw, toyota, benz, ..." besides array size variable. appreciate if help.
i've thought of loop , foreach loop don't know method in case.

$tmp = array(); foreach ($cars $car) {  $tmp[] = "personcar '%".$car."%'"; } $tmp = implode(" , ", $tmp); //" or " if want person owns of cars  mysql_query("select * person {$tmp};"); 

Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -