我想通過使用mysql來檢索它,將這一行硬編碼圖像轉換爲動態代碼。使用php mysql動態顯示圖像
<div class="item-block-1">
<span class="tag-sale"></span>
<div class="image-wrapper">
<div class="image">
<div class="overlay">
<div class="position">
<div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam quis metus non erat tincidunt consectetur. Maecenas ac turpis id lorem.</p>
<a href="#" class="quickshop">Quick shop</a>
</div>
</div>
</div>
<a href="#"><img src="images/photos/photo-3.jpg" style="margin: -32.5px 0 0 0;" alt="" /></a>
</div>
</div>
<h2><a href="pandora-item.html">Polka dot light blue blouse</a></h2>
<p class="price">$13.99<s>$36.99</s></p>
</div>
我的動態代碼如下,但只允許我檢索,而不是通過代碼循環只有一個形象..
<div class="item-block-1">
<div class="image-wrapper">
<div class="image">
<div class="overlay">
<div class="position">
<div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam quis metus non erat tincidunt consectetur. Maecenas ac turpis id lorem.</p>
<a href="#" class="quickshop">Quick shop</a>
</div>
</div>
</div>
<?php
$result = mysql_query("SELECT * FROM my_image", $connection);
while($row = mysql_fetch_array($result))
{
echo "<div><img src=\"uploadedimages/".$row['name']."\" /></div>";
}
?>
</div>
</div>
任何人都可以糾正我?
首先,你應該認真考慮切換到mysqli_ *或PDO,mysql_ *已被棄用從PHP 5.5.0 – Kostis
感謝您的意見,我仍然是一個學生嘗試一些教程..你能幫我以上? – user3145668
按下'ctrl + u'並在瀏覽器中檢查呈現的源代碼以檢查img'src',或者您可以在瀏覽器中安裝並使用'firebug'工具或開發人員工具 –