php - mysqli_query "where = $some_array" need just one match -
possible duplicate:
i have array of integers, how use each 1 in mysql query (in php)?
i trying create filtering function , know if possible, within mysqli query, check if table row has value equal 1 of in array. hope code make clearer:
$age=array(37,35); $query = mysqli_query($link, "select * users age = $age"); so want query return rows of users age either 37 or 35, above code doesn't work.
using
...where age = 35 or age = 37" won't do, because want dynamic speak.
thanks
use sql's in() clause.
sql example:
select * users age in (35, 37) php example:
$query = "select * users age in (" . implode(',', array_map('intval', $age)) . ")"; note: mindful of sql injection.
Comments
Post a Comment