Jump to content

[SOLVED] Trying to use php code in an inline style sheet


ktrollinger

Recommended Posts

Hi - trying to use an inline style to dynamically place a background image - then use html text on top of that image for higher SEO/ Google Quality score.

 

Tried escaping with no luck

 

Working hard-coded example: background-image: url(images/Bar_Chair_only.jpg);

 

Tested and no work version:

 

<style type="text/css">

<!--

.product_bg_img {

background-image: url(/images/<\?php echo \$row_qProduct\['Large_Image'\]; \?>);

background-repeat: no-repeat;

}

-->

</style>

 

Any help appreciated.

Link to comment
Share on other sites

Thanks

 

Looks very close - though the extra "/images/" piece is killing me. My bad, though. . .the path is in the  <?php echo $image; ?> so i am getting doubled - as in  /images/images/xxxx.jpg

 

I tried removing the "/images/" and couple other things with no luck.

 

Thanks.

Link to comment
Share on other sites

Solved!

 

back slash before the "?php echo $image; ?>" did the trick

 

<?php

$image = $row_qProduct['Large_Image'];

?>

 

<style type="text/css">

<!--

.product_bg_img {

background-image: url("/<?php echo $image; ?>");

background-repeat: no-repeat;

}

-->

</style>

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.