I this PHP foreach code properly written?
$colors = $_GET['color'];
$i = 0;
foreach (explode(' ', $colors) as $color)
{
$items = $con -> prepare(
"SELECT * FROM item_descr WHERE color_base1 = :colorbase1");
$items -> bindValue(":colorbase1", $color[$i]);
$i++;
}
I cannot get the SQL to work.
I think this should do what you’re asking – you’re generating
$coloras a variable in the foreach, but you were accessing it as an array.