Display summed values of a column in html

Asked

Viewed 28 times

-1

I have the qtd_stock column in the cadastral table. In a div, I want to display the values of all lines summed.

I tried this way, which does not show any value:

<?php
                    $sql2 = mysqli_query($conexao, "SELECT sum(qtd_estoque) FROM cadastraproduto");
                    $linhas = mysqli_num_rows($sql2);
                    while($linhas = mysqli_fetch_array($sql2)){
                    $linhas['sum(qtd_estoque)'];
                ?>

                <?php
                    }
                ?>

Displaying:

    <div class="col-md-3 view-produto-estoque">
                                <p class="p-dashboard"> Estoque </p>
                                <h2 class="p-toal-produtos"><?php echo $linhas; ?></h2>
</div>

1 answer

1

  • I just saw that if I put echo next to while, the value is displayed. I think my mistake is in pulling that value in the <H2>

Browser other questions tagged

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