I have 2 string :
$data1 = "8,11,";
$data2 = "2,3,";
and I do this :
$stuff = explode(",", $data1, -1);
$amount = explode(",", $data2, -1);
So the array like this :
$stuff have an Array ( [0] => 8 [1] => 11 )
$amount have an Array ( [0] => 2 [1] => 3 )
and then do foreach like this :
foreach($stuff as $index => $value){
$query= "SELECT * FROM products WHERE id = ?";
$STH2 = $DBH->prepare($query);
$STH2->execute(array($value['0']));
while($Products_all = $STH2->fetch()){
and so on....
.......
What I want to do is to print product id 8 and id 11. In fact, it get product id 8 and id 1. What's wrong with my code? Why it has product id 1 not 11? Thank you.
additional question: why it has to change to "$value" ?