Answer the question
In order to leave comments, you need to log in
PDO/MySQLi and array in query?
good time of day). There is such an array in the $jsondecoded variable:
array (size=3)
0 => string 'B' (length=1)
1 => string 'C' (length=1)
2 => string 'D' (length=1)
SELECT * FROM news WHERE id = /* значения $jsondecoded... eg. (B || C || D) */
Answer the question
In order to leave comments, you need to log in
$ids = array('B','C','D'); // ваш $jsondecoded массив
$marks = implode(',', array_fill(0, count($ids), '?'));
$stmt = $pdo->prepare("SELECT * FROM news WHERE id IN ($marks)");
foreach ($ids as $k => $id) {
$stmt->bindValue(($k+1), $id);
}
$stmt->execute();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question