dsedug8644 2014-08-24 07:23
浏览 37

当图像不可用时显示另一个图像

i have a code which gets images from a database. I need to tell it to to display another image (which says no image available) if an image is not found. How would I do this????

Your suggestions would be very much appreciated

<a class="thumbimage" href="<?PHP mrd("$MyProductTitle", "$row[LID]", "$_GET[category]", "$rowxxx[MR]", "index.php?page=detail"); ?>"><img src="images/thumb/<?php echo "$row[IMAGENAME]"; ?>.jpg" border="1" /></a>
  • 写回答

2条回答 默认 最新

  • dongmei9203 2014-08-24 07:28
    关注

    Try this:

    <?php
        $currentImage = "images/thumb/".$row[IMAGENAME].".jpg";
        if(!file_exists($currentImage))
        {
            $currentImage = "PATH_TO_IMAGE_UNAVAILABLE";
        }
    ?>
    
    <a class="thumbimage" href="<?PHP mrd("$MyProductTitle", "$row[LID]", "$_GET[category]", "$rowxxx[MR]", "index.php?page=detail"); ?>"><img src="<?=$currentImage?>" border="1" /></a>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?