我正在从数据库中拉出我的图像,以便在我的页面上显示它,但是它不会显示。为了确认图像是从数据库中调用的,我在title=上输出了图像名称。当您将鼠标放在看不见的图像上时,您可以看到图像名称,但是图像本身根本不会显示。网址是:http://clicktravelnstay.com/desti_list.php?details=19
  <div id="imgdisplay">
                     <div class="pagecontainer">
                         <div class="galleryCredit">Hotel Photos</div>
                         <div class="galleryType">Preview</div>
                         <div class="clear_both"></div>
                         <div class="galleryContent">
                                 <!--image goes herewidth:650px; height:300px;-->
                                 <!--This is Where the wide image and the caption icon will be placed-->
                                    <div class="galleryThumbnail">
                                    <?php
                                        $query = "SELECT * FROM image WHERE hotel_id = {$hotel['hotel_id']}";
                                                  $image_set =  mysql_query($query,$connection);
                                                  while($image = mysql_fetch_array($image_set)){?>
                                                  <a href=\"img/photos/<?php $image['image_url'];?>" title="<?php echo $image['image_url']?>">
                                                  <img src="img/photos/<?php echo $image['image_url'];?>" width="75" height="75"/></a>           
                                                  <?php } ?> 
                                    <div class="clear_both"></div>
                                    </div>
                                    <div class="galleryPreview">
                                    </div>
                                    <div class="clear_both"></div>
                                    <div class="clear_both"></div>
                                    <div class="gallery_preload_area"></div>
                            </div>
                     <!--image goes herewidth:650px; height:300px;-->
                     </div>以下代码是图片库的Jquery代码。
$(document).ready(function(){
$(".galleryThumbnail a").click(function(e){
     e.preventDefault();
     //update thumbnail
     $(".galleryThumbnail a").removeClass("selected");
     $(".galleryThumbnail a").children().css("opacity","1");
     $(this).addClass("selected");
     $(this).children().css("opacity",".4");
     //setup thumbnails
     var photoCaption = $(this).attr('title');
     var photofullsize =$(this).attr('href');
         $(".galleryPreview").fadeOut(500, function(){ 
         $(".gallery_preload_area").html("")  
           // this is what is going to happen after the fadeout
           $(".galleryPreview").html("<a  href='"+ photofullsize +"' style=' background-image:url("+photofullsize+");'></a>");
           $(".galleryCaption").html("<p><a href='"+photofullsize+"' title='Click to view large'>View Large</a></p><p></p>")    
           $(".galleryPreview").fadeIn(500);
          });
});
});发布于 2012-08-12 02:07:12
路径
http://clicktravelnstay.com/img/photos/1344707033.png
返回404 (未找到)。
您正在成功地从数据库中提取图像名称,但服务器上不存在实际的图像文件。
发布于 2012-08-12 02:08:28
您应该查看生成的HTML:
<a href=\"img/photos/" title="1344707033.png">
        ^--- bad escape.您输出的是无效的html,而且href只是一个路径,而不是指向实际的图像。
这意味着:
<a href=\"img/photos/<?php $image['image_url'];?>" title="<?php echo $image['image_url']?>">
                          ^---missing 'echo' 
    <img src="img/photos/<?php echo $image['image_url'];?>" width="75" height="75"/></a>而且$image['image_url']也不包含任何东西。
https://stackoverflow.com/questions/11916346
复制相似问题