2012-08-11 82 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