How to display the same data listing?

Asked

Viewed 31 times

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.

inserir a descrição da imagem aqui

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.

  • selected by idGarcon, and how many accounts you have, and add up the price if that’s the case

  • on my system , I sell fish / boiler and etc. and this data is sent to mysql, as that could list type.

  • boiler, 10 units, filet , 12 units , without having to repeat under the other several times the name of the product sold.

  • Search on count in mysql.

  • And just passing the eyes so much by, a few more are missing } to close the if ,while , unless it has omitted that part

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.