2015-09-28 67 views
0

我有這樣的代碼:PHP in_array沒有找到值,是有

$sql_zt = "SELECT 
        inh_pr.extra_bew_zetten AS extra_bew_zetten 
       FROM 5_offerte_id AS off 
       LEFT JOIN 6_offerte_inh AS off_inh 
       ON off_inh.offerte_id = off.id 
       LEFT JOIN 3_product_folder AS fld 
       ON fld.folder_id = off_inh.folder_id 
       LEFT JOIN 0_calculatie_inh_id_geg_lntk_product AS inh_pr 
       ON inh_pr.calculatie_inh_id = fld.product_id 
       WHERE off.dossier_id = ".$row['id']." AND inh_pr.extra_bew_zetten = 'ja' AND off.offerte_nr = (SELECT MAX(offerte_nr) FROM 5_offerte_id WHERE dossier_id = ".$row['id'].") "; 

if(!$res_zt = mysql_query($sql_zt,$con)) 
{ 
    include('includes/errors/database_error.php'); 
} 

if(mysql_num_rows($res_zt) > 0) 
{ 
    if(in_array('ja', mysql_fetch_array($res_zt))) 
    { 
     echo '<img border="0" src="images/icon/zetten.png" title="'.$lang['zetten'].'"> '; 
    } 
} 

這是我與查詢輸出例如: enter image description here

價值「JA」不與in_array找到。可能是什麼問題?

+0

可能有任何的虛擬空間,更是打破了比較數組中的字符串? ''ja'!='ja'' – philreed

+0

請注意'AND inh_pr.extra_bew_zetten ='ja''會呈現爲INNER JOIN – Strawberry

回答

3

有多個記錄越多,你可以使用循環爲它

while($row = mysql_fetch_array($res_zt)){ 

if(in_array('ja',$row)) 
    { 
     echo '<img border="0" src="images/icon/zetten.png" title="'.$lang['zetten'].'"> '; 
    } 
} 
+0

是的,你只測試第一行隊友,你應該循環從db中獲取的所有行 –