why is background-mage not working inline style?
[code=php]<?php
echo “<div class=’paket_title’ style=’background-image: url(‘img1.jpg’);’>
$r[head]
</div>”;
?> [/code]
it works if the code is written inside a separate CSS file, but i need to write inline because I’m using this with Switch/case statement and each case will have different image
example :
[code=php]
<?php
$bg = $r[bgcolor];
switch ($bg) {
case “red” :
echo “<div class=’paket_title’ style=’background-image :url(‘img1.jpg’);’>$r[head]</div>”;
break;
case “blue” :
echo “<div class=’paket_title’ style=’background-image :url(‘img2.jpg’);’>$r[head]</div>”;
break;
case “yellow” :
echo “<div class=’paket_title’ style=’background-image :url(‘img3.jpg’);’>$r[head]</div>”;
break;
}
?>
I tried rewriting the code, here is the list of my tries :
[code=php]
1.
echo “<div class=’paket_title’ style=’background: url(img1.jpg);’>
$r[head]
</div>”;
2.
echo “<div class=’paket_title’ style=’background-image: url(“img1.jpg”);’>
$r[head]
</div>”;
3.
echo ‘<div class=”paket_title” style=”background-image: url(“img1.jpg”);”>
$r[head]
</div>’;
4.
echo “<div class=’paket_title’ style=’background: url(/’img1.jpg/’);’>
$r[head]
</div>”;
5.
echo ‘<div class=”paket_title” style=”background: url(‘img1.jpg’);”>
$r[head]
</div>’;
echoing both background and background-image does not work, but background-color works
anyone has solution for this?