0

I'm trying to give an div a background image that is attached to a specific post (zo everytime there is another image needed). I'm retrieving the URLS out of the database and then put it into the following code:

<div class="parallax_banner" style="background-image:url(<?= "_/".$rowImage['imgPath']."/".$rowImage['imgName'] ?>)"></div>

the whole code:

<?

$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>

It's doesn't show anything, but If I test the link with <img src= instead of background-image:url() it shows up. So the path is right. How to solve this?

Tamara
  • 145
  • 1
  • 4
  • 14
  • About your tags: http://stackoverflow.com/questions/5208015/is-using-php-shorthands-bad – pdu Jan 08 '13 at 14:50

1 Answers1

0

If you are using background-* css settings you need to give the div some dimensions of height and width or it will default to none and you will not see your image.

Naftali
  • 144,921
  • 39
  • 244
  • 303