我想使用我在數據庫中做的圖像引用作爲背景:url。我已經完成了設計=> [IMG] http://i49.tinypic.com/30ihudz.png [/ IMG]。在我現在的代碼中,我使用div樣式來檢索圖像,但是沒有顯示圖像。有人請指導我嗎?提前致謝。來自數據庫的風格圖像作爲背景圖像
public function displayProduct()
{
if($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("C:/xampp/htdocs/webshop/public/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 .= '€'.$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;
}
}
您正在使用來自Windows硬盤的圖像的路徑; '「C:/ XAMPP/htdocs中/網店/公共/ IMG /內容/"'.$行[ '文件名']「。 「'這是打算的嗎?我想你應該使用一個相對於網站目錄樹的路徑,也許就像''/img/content/"'.$row['filename']'。' 「' – 2013-02-24 15:01:21