php - SQL query based on array -


this question has answer here:

i have array called $restaurantarray contains selection of restaurant id's.

is there anyway can execute mysql query return rows if id equal 1 of these restaurant id's in array?

thanks.

you can use in mysql query. implode array $restaurantarray string, using comma delimiter; cover string brackets; , use result string input query. like

// uncomment if data needs sanitized // $restaurantarray = array_map("mysql_real_escape_string", $restaurantarray); $input = '(' . implode(',', $restaurantarray) . ')'; $query = "select foo id in $input"; 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -