PHP in_array找不到那里的值

时间:2015-09-28 10:07:50

标签: php mysql

我有这段代码:

$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

价值&#39; ja&#39;找不到in_array。可能是什么问题?

1 个答案:

答案 0 :(得分: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'].'"> ';
    }
}