0
I have the following problem,
I have a system in PHP that makes a WHILE in a column of the database that contains certain values and I need WHILE to stop at a value that I determine.
The first column with the ID’s and the second with the values, I need my WHILE to perform any function until the total value of the sums of the quantities is less than or equal to 850 and then stop.
Code below:
$resultado = $PDO->query("SELECT * FROM teste");
//Variável
$i=1;
//Percorrendo e exibir registros
# Cria e abre o arquivo .txt para salvar os registros da consulta
$arquivo_total = '../imprimir/xereta.prn';
$fppp = fopen($arquivo_total, 'w');
//Percorrendo e exibir registros
while ($registro = $resultado->fetch(PDO::FETCH_ASSOC)) {
$id = $registro['id'];
$quantidade = ceil($registro['quantidade']*10/100 + ($registro['quantidade'])+20). "\r\n\n";
$i++;
# Escreve no arquivo .txt o registro atual da consulta
# Início primeira etiqueta
fwrite($fppp, $quantidade);
# Final Segunda etiqueta
} # << Fim do while
# Fecha o arquivo .txt
fclose($fppp);
Someone knows how to help me.
Why did you ask the question again? Had not already been fixed in https://answall.com/questions/461002/fazer-while-somar-at%C3%A9-determined-value-php? noredirect=1#comment875557_461002
– user60252
Good morning @Leocaracciolo the problem was that the other topic was blocked and I ended up creating another one and forgot to delete, it was a failure on my part. But anyway thank you so much for the warning.
– Jimmy Luiz Alves
Got it!! When an answer solves your difficulty mark it (the best) as accepted, see https://i.stack.Imgur.com/evLUR.png
– user60252