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

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -