When I run directly on the bank
select sum(peso) from (select peso from dados order by id asc limit 2) as subt
Returns the expected value.
When I execute in PHP with the $num=2
variable, there is no value return or error.
$consultar = ("select sum(peso) from (select peso from dados order by id asc limit $num) as subt");
$resulta = mysqli_query($link, $consultar);
while($item = mysqli_fetch_assoc($resulta)){
echo $item['subt'];
}
What I want is the sum of the values of the first two rows of the column
peso
of the table
What am I missing?
The table
DirectBankInquiry