1
I am creating a sales system and would like to list the quantity sold of each product. So it would not be repeating the name of the product but only the quantity sold.
The shape I made is like this but I would like suggestions .
<?php if($_GET['busca'] == "data"){
$datai = date('Y/m/d', strtotime($_POST['datai']));
$dataf = date('Y/m/d', strtotime($_POST['dataf']));
$hora1 = $_POST['hora1'];
$hora2 = $_POST['hora2'];
$garcon = $_POST['idGarcon'];
$query = mysqli_query("SELECT data, nome, preco, SUM(preco) AS pr, SUM(qtd) AS qtd, date_format(data, '%d/%m/%Y') AS data FROM tbl_carrinho WHERE idGarcon='$garcon' AND data BETWEEN '$datai' AND '$dataf' AND time BETWEEN '$hora1' AND '$hora2' GROUP BY data") or die(mysqli_error());
$sel = mysqli_query("SELECT * FROM tbl_carrinho")or die(mysqli_error());
while($resultado = mysqli_fetch_array($query)){
$ids = $resultado['idGarcon'];
$oo = mysqli_query("SELECT * FROM garcon WHERE idGarcon='$garcon'")or die(mysqli_error());
$todos = mysqli_fetch_assoc($oo);
$nome_garcon = $todos['nomeGarcon'];
$data = $resultado['data'];
$nome = $resultado['nome'];
$qtd = $resultado['qtd'];
$preco_unitario = $resultado['preco'];
$precototal = $resultado['pr'];
$total_produto = $qtd * $preco_unitario;
$total += $total_produto;
$comi = mysqli_query("SELECT * FROM config");
$valor = mysqli_fetch_array($comi);
$venda = $valor['pgarcon'];
$ganho += $total_produto * $venda / 100;
?>
If you explain to me how the word guy improved understanding of his first sentence, I even trying help.
– user86792
selected by
idGarcon
, and how many accounts you have, and add up the price if that’s the case– 13dev
on my system , I sell fish / boiler and etc. and this data is sent to mysql, as that could list type.
– Allan Almeida De Araujo
boiler, 10 units, filet , 12 units , without having to repeat under the other several times the name of the product sold.
– Allan Almeida De Araujo
Search on
count
in mysql.– Max Rogério
And just passing the eyes so much by, a few more are missing
}
to close theif
,while
, unless it has omitted that part– Isac