0

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?

2
  • Could there be any spaces in the strings in the array which is breaking the comparison? 'ja' != 'ja ' Commented Sep 28, 2015 at 10:10
  • Note that AND inh_pr.extra_bew_zetten = 'ja' will render as an INNER JOIN Commented Sep 28, 2015 at 10:21

1 Answer 1

3

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'].'"> ';
    }
}
Sign up to request clarification or add additional context in comments.

1 Comment

Yup, you were testing only the first row mate, you should loop all rows fetched from the db

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.