Jump to content

[SOLVED] use a different file when the image is unavailable


akreation

Recommended Posts

How do I replace, or use a different "image unavailable" file when the image is unavailable?

Example::
If image1.jpg is unavailable the use image2.jpg

The code below is the image that is unavailable sometimes, because all records do not have images.
[code]
<img src="/scripts/phpThumb/phpThumb.php?src=/SaMPLe/Regional/<?php echo $row_rs_flavor_details['regional']; ?>/<?php echo $row_rs_flavor_details['country']; ?>/<?php echo $row_rs_flavor_details['state_province']; ?>/<?php echo $row_rs_flavor_details['flavor_id']; ?>2.jpg&w=150&h=150" border="0">
[/code]

Hope this is clear enough, thanks in advance, and forgive the newbe.
Thanks SA, thats what i need, just haing a little trouble with my code. I tried the ones below with no luck.

[code]
<?php
$path = "/SaMPLe/Regional/<?php echo $row_rs_flavor_details['regional']; ?>/<?php echo $row_rs_flavor_details['country']; ?>/<?php echo $row_rs_flavor_details['state_province']; ?>/<?php echo $row_rs_flavor_details['flavor_id']; ?>1.jpg";
$path = (file_exists($path)) ? $path : "/images/whowont_logo.jpg";
echo "<img src='$path' alt='My Image' />";
?>
[/code]
[code]
<a href="/SaMPLe/Regional/<?php echo $row_rs_flavor_details['regional']; ?>/<?php echo $row_rs_flavor_details['country']; ?>/<?php echo $row_rs_flavor_details['state_province']; ?>/<?php echo $row_rs_flavor_details['flavor_id']; ?>1.jpg">
<img src="<?php $path = "/scripts/phpThumb/phpThumb.php?src=/SaMPLe/Regional/<?php echo $row_rs_flavor_details['regional']; ?>/<?php echo $row_rs_flavor_details['country']; ?>/<?php echo $row_rs_flavor_details['state_province']; ?>/<?php echo $row_rs_flavor_details['flavor_id']; ?>1.jpg&w=150&h=150";
$path = (file_exists($path)) ? $path : "/images/whowont_logo.jpg";
echo "<img src='$path' alt='Legendary Place Image One' />";
?></a>
[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.