而如果,否则组合[复制]

This question already has an answer here:

I try to extract data from database below, and as a result, for example, as below is low risk, I want to show an image and, at average risk, another image. But it does not work. What is wrong?

<?php

if ($_POST) {
    $ara = $_POST["ara"];

    $sorgu = mysqli_query($baglan, "select Risk from wanbetaler where BTW like '%$ara%'");
    if (empty($ara)) {
        echo 'GEEN RESULTAAT';
    } else {
        if (mysqli_num_rows($sorgu) > 0) {
            while ($kayit = mysqli_fetch_array($sorgu)) {
                if ($kayit = "Low risk") {

                    echo '<center> <img src="groen.jpg" class="center" /></center>';

                } elseif ($kayit = "Average risk") {

                    echo '<center> <img src="oranje.JPG" class="center" /></center>';

                }

            }
        } else {
            echo 'GEEN RESULTAAT';
        }
    }
} else {

}
?>
</div>

couple things.

  1. you're comparing an array, use $kayit[0] or $kayit['Risk']

  2. you're using the wrong operator. You need to use == in the comparisons.