I have an identifier string like 1,2,3,4,5 and I want to be able to list all the rows in mysql where the identifier is in this list.
I assumed that the easiest way would be to turn the string into an array and then combine it into ($ array), but it does not work for me - no errors, etc., but it does not return strings:
$string="1,2,3,4,5"; $array=array_map('intval', explode(',', $string)); $query=mysqli_query($conn, "SELECT name FROM users WHERE id IN ('".$array."')");
If I do var_dump of the $ array, I get:
array(5) { [0]=> int(1) [1]=> int(2) [2]=> int(3) [3]=> int(4) [4]=> int(5) }
Any idea where I'm screwing up?
source share