Show the total amount only if it is as PAYMENT

0

I have a selection system that sends PAYMENT to the database as ID: 1 and NOT PAYED as ID: 0, and I did a check instead of appearing the value 1 or 0 appears PAYMENT or NOT PAYMENT. So far so good, plus a system in the same table that is called "Total Value", where it takes all the values from the database ads and shows on the screen, and I wanted it to show the value of the ad only if it is as NOT PAID, those that are PAID it does not show in Total Value. I did an even more anyway so it did not work and this bugando, could someone help me?

                <th style="text-align:center;">Valor Total: R$ <?php
                if($anuncio['estado'] == 1){
                $sql = $pdo->prepare("SELECT SUM(valor) AS total FROM 
                anuncios WHERE id_usuario = :id_usuario");
                $sql->bindValue(":id_usuario", $_SESSION['cLogin']);
                $sql->execute();

                $ln = $sql->fetchObject();

                echo number_format($ln->total);
                }
                ?></th>
    
asked by anonymous 22.10.2017 / 06:41

0 answers