-2

I have a select from the database working fine, all the fields are comming correct, but in the php file I created an if to chech if the updates= to 0 or 1, but is not working, the varialbe $up always assume the same value although in the database are diferent.

I want a thumbs up if the database value is 1 and a thumbs down is the database value is 0.

database print

result print

 <?php
 include ("db.php");
    $admin_query="SELECT id, nome, email, updates FROM atualizacao";
     $run_query = mysqli_query($con,$admin_query);

    if (mysqli_num_rows($run_query) > 0){

        while($row = mysqli_fetch_array($run_query)){
            $id=$row['id'];
            $nome=$row['nome'];
            $email=$row['email'];
            $updates=$row['updates'];
            if($updates="0"){
                $up="<i class='fa fa-thumbs-down' style='font-size:24px'></i>" ; 
            }else{
                $up="<i class='fa fa-thumbs-up' style='font-size:24px'></i>";
            }
           echo
            "<div class='card mx-auto w-100'>
                <div class='card-body'>
                        <div class='row'>
                        <div class='col-md-2' style='text-align: center'>$id</div>
                        <div class='col-md-2' style='text-align: center'>$nome</div>
                        <div class='col-md-2' style='text-align: center'>$email</div>
                        <div class='col-md-2' style='text-align: center'>$up</div>
                    </div>
                </div>
            </div>
           ";
       }
    }
    ?>
edshewa
  • 21
  • 1
  • 6

1 Answers1

0

You are not making a comparison but an assignment in your condition:

if($updates="0")

This will always return true, you need to change it to:

if ($updates == "0")

See the comparison operators in PHP.

AymDev
  • 6,626
  • 4
  • 29
  • 52