我正在尝试为 div 提供附加到特定帖子的背景图像(每次需要另一个图像时都会出现)。我正在从数据库中检索 URLS,然后将其放入以下代码中:
<div class="parallax_banner" style="background-image:url(<?= "_/".$rowImage['imgPath']."/".$rowImage['imgName'] ?>)"></div>
整个代码:
<?
$result = mysql_query("SELECT * FROM `items` WHERE `itemID` = ".$_GET['postID'])or die(mysql_error());
while ($row = mysql_fetch_assoc($result)) {
$resultImage = mysql_query("SELECT * FROM `images` WHERE `itemID` =".$row['itemID']." LIMIT 1")or die(mysql_error());
while ($rowImage = mysql_fetch_assoc($resultImage)) {
?>
<div class="paginaBannerWrapper">
<div class="paginaBannerSlideshow">
<div class="parallax_banner" style="background-image:url(<?= "_/".$rowImage['imgPath']."/".$rowImage['imgName'] ?>)"></div>
</div>
</div>
<div id="content">
<div id="bigTitle">
<h1><?=$row['itemTitle']?></h1>
</div>
<div id="centerContent">
<div id="colDesc">
<div class="itemContent"><?=$row['itemContent']?></div>
</div>
<div id="colImg"><img src="<?= "_/".$rowImage['imgPath']."/".$rowImage['imgName'] ?>"/></div>
<?
}
}
?>
</div>
</div>
它没有显示任何内容,但是如果我测试链接<img src=
而不是background-image:url()
显示它。所以这条路是对的。如何解决这个问题?