Hi

I have been struggling with this for a while and cant find the answer, the code below shows my else if statement everything goes fine until using the else if statement and ' . $img . ' ends up being blank.

It should be if field 4 is 0.00 then ' . $img . ' should be nothing
else if field 4 is blank then ' . $img . ' should be nothing
else there is something in field 4 then ' . $img . ' should be <img src="/images/' . ($row['field4']) . '.jpg" height ="60" border="0" ALIGN="Left" />

All 3 come up with no code at all in the place where ' . $img . ' should be

Please help

$result = mysql_query("SELECT DISTINCT `field1`, `field2`, `field3`, `field4` FROM TABLE WHERE `field1` = '$txt1' and `field2` = '$txt2'") or trigger_error(mysql_error().$sql);
while($row = mysql_fetch_array($result)){


                                if($row['field4'] == 0.00)
                        {
                            $img = '';
                        }
                        else
                        {
                            if($row['field4'] ='')
                            {

                                $img = '';

                            }
                            else
                            {

                                $osimg = '<img src="../'. $row['field4'].'" height ="150" border="0" ALIGN="Left" />';

                            }
                        }

echo '
                                  <img src="../'. $row['field3'].'" height ="150" border="0" ALIGN="Left" alt="'. $row['field1'].' '. $row['field2'].'" />' . $img . '';
}

?>

Recommended Answers

All 6 Replies

On line 20, you have $osimg = ..., shouldn't this be $img = ...? From the code you currently have, $img will never be assigned a value if it field4 contains a value.

OK thanks, how would I change it so I do have a value please

Just change $osimg to $img on line 20 and give that a go.

No that has not worked

line 11 must have double equal to, comparison, u put only 1

if($row['field4'] ='')

make it

if($row['field4'] =='')

thanks, all sorted now

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.