Display image if XML value is

Hello, trying to work out the solution to having my code display a particular images depending on the value the xml returns…

> <property>
>    <status>**The returned values/varibles are : available, sold, let, under offer, sold subject to contract.**</status>
> </property>

I’m using <?php echo $aRow->status; ?> to return a value, now need to display an image depending on the returned values. Just cant work out the if/else!
Thanks in advance

Name your images to correspond to the status values, then use something like

echo '<img src="/images/statusicons/"' . $aRow->status . '".jpg" alt="' . $aRow->status . '" />';

No ifs and elses required.

If you can’t do that, either link the status code to the image name in a database table so it’s easy to change later, or look at the switch() construction.

1 Like

Boom, there is it. Damn it was so simple! You sir, are a saviour. Been banging my head on this all morning!!

Thank you so much!!

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.