In my loop, I have only one result.
The array result:
array(3) {
[3]=>
array(1) {
["qty"]=> int(2)
}
[1]=>
array(1) {
["qty"]=> int(3)
}
[2]=>
array(1) {
["qty"]=> int(4)
}
}
If I write this inside the loop, it displays just one one result:
var_dump('Key=' . $key .' - Value=' . $value['qty']);
My loop:
foreach ($this->products as $key => $value) {
$QProducts = $this->db->prepare('select p.products_id,
pd.products_name,
p.products_model
from :table_products p,
:table_products_description pd
where p.products_id = :products_id
and p.products_id = pd.products_id
');
$QProducts->bindInt(':products_id', $key);
$QProducts->execute();
echo $QProducts->value('products_name');
}
How can I solve this problem?
Below the main element of the function . It can help you.
public function OrderProduts() {
$prod_array = $this->orderResult['Cart']['contents'];
foreach ($prod_array as $key => $value) {
$QProducts = $this->db->prepare('select p.products_id,
pd.products_name
from :table_products p,
:table_products_description pd
where p.products_id = :products_id
and p.products_id = pd.products_id
');
$QProducts->bindInt(':products_id', $key);
$QProducts->execute();
echo $Products->value('products_name);
echo $value ['qty'];
}
}
count($this->products)?