mysqli_query讓我學士學位,如果應該是10的結果,但我得到的結果15.是不是作爲字符串輸出學士學位?這個怎麼做?錯誤的結果在PHP
<?php $levelofeducation = mysqli_query($con,"SELECT levelofeducation AS value FROM retailmain WHERE id='1'");
if ($levelofeducation == "Elementary/H School"){echo "0";}
elseif ($levelofeducation == "JR Coll") {echo "5";}
elseif ($levelofeducation == "Bachelors"){echo "10";}
else {echo "15";}
?>
您需要循環查詢的結果,然後進行比較。 – 2014-12-02 20:48:18
您需要查看示例並瞭解如何從查詢結果中獲取行,然後瞭解如何訪問行中的值。 – AbraCadaver 2014-12-02 20:48:35
,你正在分配$ levelofeducation1,但試圖訪問$ levelofeducation - 這就是爲什麼你總是得到15,因爲它總是擊中else。 – 2014-12-02 20:48:45