2017-07-12 109 views
-4

我尝试从下面的数据库中提取数据,因此,例如,如下所示是低风险,我想显示一幅图像并且平均风险下显示另一幅图像。但它不起作用。哪里不对?while if else else

<?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 { 

} 
?> 
+0

“不工作” - 它有什么作用 – clearshot66

+0

[小博](http://bobby-tables.com/)说***脚本是在对SQL注入攻击的风险。( http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php)***了解[编写]​​(http://en.wikipedia.org/wiki/Prepared_statement )[MySQLi]的声明(http://php.net/manual/en/mysqli.quickstart.prepared-statements.php)。即使[转义字符串](http://stackoverflow.com/questions/5741187/sql-injection-that-gets-around-mysql-real-escape-string)是不安全的! –

回答

0

夫妇的事情。

  1. 你比较数组,使用$kayit[0]$kayit['Risk']

  2. 你使用了错误的操作。您需要在比较中使用==