0

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

?>
3
Contributors
6
Replies
7
Views
4 Years
Discussion Span
Last Post by mpc123
0

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.

0

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

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

make it

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.