2013-02-24 100 views
-1

我想將我在數據庫中創建的圖像引用用作背景:url。我已經完成了設計=>http://i49.tinypic.com/30ihudz.png在我當前的代碼中,我使用div樣式來檢索圖像,但沒有顯示圖像。有人請指導我嗎?提前致謝。從後臺數據庫中檢索圖像名稱:url

公共函數displayProduct() {

 $product = $this->db->query("SELECT id, title, description, price, filename FROM trips ORDER BY id"); 

      while ($row = $product->fetch_assoc()) 
         { 
        $output .= '<div class="reisbox">'; 
          $output .= '<div id="reis_insidebox1" style="background: url(\'img/content/'.$row['filename'].'\')" width="1000" height="500">'; 
        $output .= '<div class="reis_textbox">'; 
        $output .= '<h2>'.ucfirst($row['title']).'</h2>'; 
          $output .= '<article>'; 
          $output .= ucfirst($row['description']); 
          $output .= '</article>'; 
          $output .= '</div>'; 
        $output .= '<div class="rightboxx">'; 
        $output .= '<div class="reis_price_box">'; 
          $output .= '<div class="reis_price_box_text">'; 
          $output .= '&euro;'.$row['price']; 
          $output .= '</div>'; 
          $output .= '<div class="more_box">'; 
          $output .= '<a href="index.php?page=reis.php&pid='.$row['id'].'"><p>Lees meer..</p></a>'; 
          $output .= '</div>'; 
          $output .= '</div>'; 
          $output .= '</div>'; 
          $output .='<br />'; 
          $output .= '<div id="add">'; 
          $output .='<a href="index.php?page=cart.php&action=add&id='.$row['id'].'"><p>Add to cart</p></a>'; 
          $output .= '</div>'; 
        $output .= '</div>'; 
          $output .= '</div>'; 
       } 
       return $output; 


    } 

回答

0

C:/不是一個URL,因爲它沒有的協議(如文件:或http :)。使路徑指向htdocs文件夾內的文件,如

"http://localhost/images/" 

或其他。

+0

謝謝,我編輯過,但問題仍未解決 – user2031928 2013-02-24 15:20:00

+0

當您查看頁面源代碼時,是否在代碼中看到正確的URL?如果是這樣,請將其剪下並直接將URL粘貼到瀏覽器的地址欄中。如果這不顯示圖像,您的瀏覽器無法訪問該文件。 – 2013-02-24 17:05:55

+0

我修好了,我修改了代碼 – user2031928 2013-02-24 17:17:54