Reputation: 2188
Please I want to know if its possible to search a database table with an array for example:
$array = array('a', 'b', 'c', 'd', 'e');
$query = mysqli_query($con, "SELECT * FROM table WHERE //the possible search for each of the array value// (!in_array(table_colomn, $array)");
Is there a possible way to do this or do I have to run a for each function like so:
foreach($array as $arr){
//run table query search for each array value
}
Upvotes: 0
Views: 80
Reputation: 153
Here is the way to do it.
$array = array('a', 'b', 'c', 'd', 'e');
$query = "SELECT * FROM table WHERE `column` IN ('".implode("', '", $array)."');";
$query = mysqli_query($con, $query);
Upvotes: 4