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
https://forums.phpfreaks.com/topic/26447-if-statement-help/
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
https://forums.phpfreaks.com/topic/26447-if-statement-help/#findComment-120948
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
https://forums.phpfreaks.com/topic/26447-if-statement-help/#findComment-120951
Share on other sites

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.