Jump to content

PHP and mysql results in CSS


bschultz

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.