我有来自用户的两个数组输入。一个是产品的ID,另一个是产品的数量。当用户输入相同数量的金额时(例如5 mallboro,7 coca cola,6 fanta,5 pepsi),我的问题就出现了。代码只显示百事可乐,但不显示mallboro。哪里有问题?金额是$ kolicina变量。这是我的代码
$idProizvod = implode(',', array_reverse($_POST['idProizvod']));
$kolicina = implode(",", $_POST['kolicina']);
$kolicina = array_reverse($_POST['kolicina']);
$sql="SELECT kodProizvoda,imeProizvoda,jedinica,cijena FROM proizvodi WHERE memberID IN ($idProizvod) ORDER BY FIELD(memberID, $idProizvod)";
$result=mysqli_query($con,$sql);
// Fetch all
$array= mysqli_fetch_all($result,MYSQLI_ASSOC);
$brojac = 0;
foreach (array_combine($kolicina, $array) as $code => $name) {
$name= implode("<td>", $name);
echo '<tr>';
echo '<td> <input type="number" id="'.$brojac.'" class="kol" name="kolicina[]" value="'.$code.'"></td>';
echo '<td> '.$name.'</td>';
echo '<td id="iznostbl'.$brojac.'"> </td>';
echo '</tr>';
$brojac++;
}
}