View Full Version : If / Else statments with images

04-12-2006, 04:58 AM
Hi all,

I have some thumbnail being generated form the database but i need a way to have it display a default image if the image hasn;t been uploaded yet or if there is no image.

Here is the code generating the image right now

<tr align="left" valign="top">
<td width="250" rowspan="2">

/picgallery/<?php echo $row_rsLandscapes['thumbs']; ?></p>

Full Size</p></td>
<td width="210" class="main_text"><span class="large_bold"><?php echo $row_rsLandscapes['title']; ?></span>

<?php echo $row_rsLandscapes['desc']; ?></td>

I have another image called "not_avail.jpg" that i need to display if the intended image is not there.

Please help!!

04-12-2006, 07:30 AM
<tr align="left" valign="top">
<td width="250" rowspan="2">

<?php if($row_rsLandscapes['thumbs'] !=''){ ?>

/picgallery/<?php echo $row_rsLandscapes['thumbs']; ?>

<?php } else {?>


<?php } ?>


Full Size</p>

<td width="210" class="main_text">
<span class="large_bold">
<?php echo $row_rsLandscapes['title']; ?>

<?php echo $row_rsLandscapes['desc']; ?>

04-12-2006, 01:50 PM

One more quick question though...
Right now it checks for an empty field right? What if the image name and image descritpion are spelled two different ways? I need the image to show then as well...

Any ideas???

04-12-2006, 02:56 PM
if your image name in the database is spelled differently from the file then this is going to cause problems

how would the application know that a spelling error has occured

image1.jpg == imge1.jpg

how would the application know that the above example is a typo and not another image ?

04-12-2006, 03:38 PM
DB Structure is as follows

I have the client updating the DB using the insert record server behaviour. Images are uploaded to the /picgallery folder using a php upload script. So by doing this he has to type in the EXACT name of the image he has uploaded with php script into the 'thumbs' and 'fullsize' category.

ie: if the image name is 'example_thumb.jpg' he would use the script to upload the image and then go to the insert form and in the thumbnail field he would have to ensure that he types in example_thumb.jpg exactly as it is named.

I hope I have made sense of all this..