Jump to content

if statement help


ltoto

Recommended Posts

right i simply want to put an if state around this to do the following

: if there is no picture, show nothing:

around this

[code]<li><a href="/pages/showimage0.php?hotelId=<?php echo $row_rsAccom['hotelId'];?>" target="_blank"><img src="../thumb/phpThumb.php?src=../images/hotel_<?php echo $row_rsAccom['hotelImage1']; ?>&w=50&h=50&zc=1&err=../images/noimage1.jpg" border="0"Latest Deals></a></li>[/code]
Link to comment
Share on other sites

Well i see that you havent read the PHP guide about IF statements.. to bad

but i'll help you abit..

[code]
<?php
?>
<li><a href="/pages/showimage0.php?hotelId=<?php echo $row_rsAccom['hotelId'];?>" target="_blank">
<?php
if (file_exists('../images/hotel_' . $row_rsAccom['hotelImage1']))
{
   echo '<img src="../thumb/phpThumb.php?src=../images/hotel_<?php echo $row_rsAccom['hotelImage1'] . '">';
}
else
{
   echo '<img src="../images/noimage1.jpg" border="0">';
}

echo 'Latest Deals></a></li>';
?>
[/code]

something like this.. (out of my head... so not tested in anyway!)
Link to comment
Share on other sites

The syntax of the given solution is incorrect, try:
[code]<?php
if (file_exists('../images/hotel_' . $row_rsAccom['hotelImage1']))
    echo '<img src="../thumb/phpThumb.php?src=../images/hotel_' .  $row_rsAccom['hotelImage1'] . '">';
else
    echo '<img src="../images/noimage1.jpg" border="0">';
echo 'Latest Deals></a></li>';
?>[/code]

Ken
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.