pass the page id to the css.php

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Hello all,

Is there a way to pass the page id to the css?

My css is a .php i.e. "css.php"

i need to pick up the page id xxx.php?pgID=2 so that i can display
multiple images based the page id.

the css queries a table to see if the header_image field is not null.
if it is not null it uses the image name in that field for the
#mainpic background image

here is the code from the css file:

#mainpic {

        $pageID = $_GET['pgID'];
        $iquery = "SELECT header_image FROM articles WHERE art_id =
        $iresult = mysql_query($iquery);
        if ($iresult)
        $iarray = mysql_fetch_array($iresult);
        $headerimage = $iarray['header_image'];
        if (strlen($headerimage) > 0)
        print "background-image: url(/pics/header/".$headerimage.");\n";
        if (strlen($szHeaderBackgroundColor) > 0)
            print "background-color: #".$szHeaderBackgroundColor.";\n";
        if (strlen($szHeaderPic) > 0)
            print "background-image: url(/pics/header/".$szHeaderPic.");\n";


    background-repeat: no-repeat;
    background-position: center 0;
    width: 724px

Everything works great. I have tested it by assigning and id to the
$pageID variable. my only issue is getting the page id to this file.

Any help would be greatly appreciated.

God bless

Re: pass the page id to the css.php

jsd219 wrote:
Quoted text here. Click to load it

I never thought of doing this, but it sounds very nice.

Frankly, I don't see your problem.  You have (where the file has a php

<style type="text/css">
...what you have above

So, you should get the pageID since, OBVIOUSLY, you are passing it in on
the URL from the preceding, calling, page (where you know what it is).

If you don't want it clutter the page, you can have the
<style type="text/css">
...what you have above

in a separate file (call it dynCSS.php) and do a
require 'dynCSS.php';

Site Timeline