0

Hi
I'm having problems with putting an image - outofstock.gif into a table cell but only if prod_status == 'Sold'
An empty image place holder shows - but without the actual image in it.

Ideally I also wanted this whole table column to be a background to another table cell (and not in a separate column) but couldn't get that to work either.

I know something like <td background='image/outofstock' but couldn't get the if statement to work within the background setting?

<td align="center"><img src="<?php if ($row_rs_dresses['prod_status'] == "Sold") $src = 'images/outofstock.gif'; else echo 'images/dot.gif'?>" width="40" height="40" /></td>

Any ideas would be great :-)
Many thanks!

4
Contributors
6
Replies
7
Views
5 Years
Discussion Span
Last Post by simplypixie
0

Well if you are showing a image with a if statement it would be something like this;

$var = "10";

if ($var > 5) {
echo "put image tag hear";
{ 

else {
echo " $var is not grater that 5";
}

Edited by Narue: Snipped fake signature

0

@evanburry,

Try changing this part of you codes

$src = 'images/outofstock.gif';

To this

echo 'images/outofstock.gif';

Edited by veedeoo: n/a

0

As veedeoo said, or try putting the if statement outside your img tags

<?php if $row_rs_dresses['prod_status'] == "Sold") { ?>
<img src="images/outofstock.gif" width="40" height="40" />
<?php } else { ?>
<img src="images/dot.gif" width="40" height="40" />
<?php } ?>

Edited by simplypixie: n/a

0

Hi Guys
That works perfectly! Thanks. Really appreciate the responses and help.

0

I have just one more question:
Is it possible to put all that into a <td background=...</td
So that I can have the image show up as a background in a table cell, with my normal text on top of it?

Many thanks

0

You could put it into a div or class instead of the table (I can't answer your question as it is years since I put a background image set to a table cell).

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.