Skip to main content
Participant
October 11, 2007
Question

PHP inside CSS

  • October 11, 2007
  • 2 replies
  • 528 views
Hullo,

I'm trying to work out if I can add PHP script pulling dynamic images from database, inside CSS "background-image url(xx);".

Like this:

#someID {
background-image: url(../randomimage.php)
}

the PHP script works ok (done with ADDT) and shows image ok when run separately. I get no errors from CSS either, but no picture is shown. One or two sites claim that this should be ok... Maybe i'm doing it the wrong way then.

Any ideas, suggestions?

All help welcome.
This topic has been closed for replies.

2 replies

Inspiring
October 11, 2007
KK74 escreveu:
> Hullo,
>
> I'm trying to work out if I can add PHP script pulling dynamic images from
> database, inside CSS "background-image url(xx);".
......................
>
> #someID {
> background-image: url(../randomimage.php)
> }
......................
I'm using gd images as background for a lot of time without problems.
Se here a useful example, with sources:

http://www.educar.pro.br/public/all/d/
----
zerof
Inspiring
October 11, 2007
.oO(KK74)

> I'm trying to work out if I can add PHP script pulling dynamic images from
>database, inside CSS "background-image url(xx);".
>
> Like this:
>
> #someID {
> background-image: url(../randomimage.php)
> }

Sure. A URL is a URL. It doesn't matter if it points to a static
resource or a script. Just make sure that the script delivers the
correct HTTP headers.

> the PHP script works ok (done with ADDT) and shows image ok when run
>separately. I get no errors from CSS either, but no picture is shown. One or
>two sites claim that this should be ok... Maybe i'm doing it the wrong way
>then.

Can you upload a test case and post the URL?

Micha
KK74Author
Participant
October 11, 2007
Ok,

that was very quick. I guess the problem is with the http headers. If you have quick guidelines to them, please do post.

I might post the small script entirely here later today, if the headers won't make the difference.

Thank you,

KimmoK