0
I’ll try to be objective in doubt:
I have the following code:
<?php
foreach ($modelo as $k => $v) {
$sql_ = "SELECT * FROM pedido WHERE modelo LIKE '%".$v."%' ORDER BY id ASC";
$disp_sql_ = $mysqli->query($sql_);
while ($data_ = $disp_sql_->fetch_array()) {
$quantidade_ += ($data_['total'] * $data_['kit']);
}
}
The total of the variable $quantidade
, has the sum output of all models.
In the database it’s like this:
valor 1 = 20 ($modelo 1)
valor 2 = 30 ($modelo 1)
valor 3 = 50 ($modelo 1)
valor 4 = 50 ($modelo 2)
valor 5 = 50 ($modelo 2)
The variable $quantidade
brings me this:
$quantidade = 200;
What I would like you to bring me the result as follows:
$quantidade = array([0] => 100, [2] => 100)
a sum to each model change (each foreach change), results in an array.
starts the $quantity before the while
$quantidade_ = array(); while (){ $quantidade_ = array( //seucaldulo ) }
– adventistaam