2012-08-11 120 views
1

我从数据库拉我的图像,以显示它在我的网页上,但它不会显示。要确认图像正在从数据库中调用,我将标题上的图像名称输出到当您将鼠标放在不可见的图像上时,您可以看到图像名称,但图像本身完全不显示。该网站是这样的: 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); 

      }); 


}); 



}); 

回答

0

路径

http://clicktravelnstay.com/img/photos/1344707033.png

返回404(未找到)。

您正在从数据库中成功拉取图像名称,但实际图像文件不存在于您的服务器上。

+0

我刚刚检查它是在服务器 – 2012-08-11 18:21:39

+0

只是为了证实这一点。我的本地服务器发生同样的问题。 – 2012-08-11 18:25:47

+0

它返回404 - 未找到。仔细检查路径。你的第一步是获得我发布的链接返回图像。然后您可以开始排查您的代码。 – FJT 2012-08-11 18:26:31

0

你应该看看生成的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']不包含任何东西。

+0

如果它不包含任何内容,那么当你将鼠标放在它上面时它怎么可能显示图像的名称 – 2012-08-11 18:17:02

+0

如果它是一个不好的逃脱,那么请你帮助改进它。 – 2012-08-11 18:24:15