Show total value only if PAID

Asked

Viewed 33 times

0

I have a selection system that sends PAID to the database as ID: 1 and NOT PAID as ID: 0, and I did a check instead of appearing the value 1 or 0 appear PAID or NOT PAID. So far so good, plus I a system on the same table called "Total Value", where it takes all the values of the ads from the database and shows on the screen, and I wanted it to show the value of the ad only if it is as NOT PAID, the ones that are PAID he does not show in the Total Value. I did an if more still didn’t work and this bugging, someone could 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>
  • Would not be WHERE id_usuario = :id_usuario AND estado = 1?

  • So you don’t want to go.

  • Ae was, thank you <3

No answers

Browser other questions tagged

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