Muiter
Muiter

Reputation: 1520

PHP in_array is not finding value that is there

I have this code:

$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'].'"> ';
    }
}

This is my output example with the query: enter image description here

Value 'ja' is not found with in_array. What might be the problem?

Upvotes: 0

Views: 73

Answers (1)

Man Programmer
Man Programmer

Reputation: 5356

there are more than one record you can use loop for it

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

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

Upvotes: 3

Related Questions