I am struggling to bind an array of strings to an IN() clause in a MySQL statement. I have found a lot of info on this with regards to integers, but all using methods which don't work with strings.
Here's my code so far:
$dbconnect = new PDO(...);
$brands = array('Nike', 'Adidas', 'Puma');
$i = 1;
try {
$dbconnect->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$data = $dbconnect->prepare("SELECT * FROM clothing WHERE brand IN (:brands)");
$data->bindParam(':brands', $brands);
$data->execute();
while($row = $data->fetch()) {
echo $i++ . " - ". $row['brand'] . "<br>";
}
} catch(PDOException $er) {
echo 'Error: ' . $er->getMessage();
}
Thanks in advance for any help!