If I have an array of say, some ID\'s of users. How could i do something like this:
$array = array(1,40,20,55,29,48);
$sql = \"SELECT * FROM `myTable` WHERE
Use IN
:
$sql = "SELECT * FROM `myTable` WHERE `myField` IN (1,40,20,55,29,48)";
you can use implode(",", $array)
to get the list together from the array.
You want to use IN
:
WHERE `myfield` IN (1,40,20,55,29,48)
Use implode to construct the string:
$sql = "SELECT * FROM `myTable` WHERE `myField` IN (" . implode(',', $array) . ")";