Jump to content

Recommended Posts

u mean get the background path which has been stored in database?

 

if it's that what u mean then u can get the background path from your database

make sure that background image has been uploaded into your local folder n

 

<body <?php echo "background='mybackground.jpg'";?>>

 

In my CSS I have this...which sets the background image for a given "div".

 

#center_big_box.home{

background:url(/images/services.gif) no-repeat bottom left #3a3535;

 

I'd like the background:url(/images/services.gif) no-repeat bottom left #3a3535; to change like this...background:url('<?php $row[image_location]; ?>' ) no-repeat bottom left #3a3535;

 

 

But it's not working.  Like I said, I have that in my css file...which is included like any other css file.  I've even tried setting the background as a <div style=background:url('<?php $row[image_location]; ?>' )> but that didn't work either.  No images show up at all.

In my CSS I have this...which sets the background image for a given "div".

 

#center_big_box.home{

background:url(/images/services.gif) no-repeat bottom left #3a3535;

 

I'd like the background:url(/images/services.gif) no-repeat bottom left #3a3535; to change like this...background:url('<?php $row[image_location]; ?>' ) no-repeat bottom left #3a3535;

 

 

But it's not working.  Like I said, I have that in my css file...which is included like any other css file.  I've even tried setting the background as a <div style=background:url('<?php $row[image_location]; ?>' )> but that didn't work either.  No images show up at all.

 

have u tried to change this

 

background:url('<?php $row[image_location]; ?>' )

 

into this

 

 

background:url('<?php $row['image_location']; ?>' )

see the bold single quotes

In my CSS I have this...which sets the background image for a given "div".

 

#center_big_box.home{

background:url(/images/services.gif) no-repeat bottom left #3a3535;

 

I'd like the background:url(/images/services.gif) no-repeat bottom left #3a3535; to change like this...background:url('<?php $row[image_location]; ?>' ) no-repeat bottom left #3a3535;

 

 

But it's not working.  Like I said, I have that in my css file...which is included like any other css file.  I've even tried setting the background as a <div style=background:url('<?php $row[image_location]; ?>' )> but that didn't work either.  No images show up at all.

 

have u tried to change this

 

background:url('<?php $row[image_location]; ?>' )

 

into this

 

 

background:url('<?php $row['image_location']; ?>' )

see the bold single quotes

 

Didn't change anything either

I'm going to try to simplify this...and NOT change anything with the css file...and instead try to use a <div style> in the main php page. 

 

If I use the php in the style sheet, wouldn't I be including a file (the css) BEFORE I've set the variable with the mysql result?

leave the CSS alone. CSS files are not meant to by dynamic.  Style is separate from function.

 

If you want the style to change on load, then change the style with JS onload.  you can use PHP inside of JS as normal, and have the JS change the style when needed.

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.