Jump to content

Running .css as PHP (HELP!!)


db118

Recommended Posts

I am working (currently in the development phase) on a social networking type site, and i want to know how i can run my CSS pages as PHP.

 

I did a little research and dug up this http://www.webmasterworld.com/forum83/2201.htm but it is from 2003, and i dont know if it would work on the latest PHP installation.

 

I'm finalizing my database design, and a lot in the user profile and other tables depends on this concept, so if i could get a solid answer and maybe a example, that would be AWESOME.

 

I will be using this basically....

 

#profile.css

 

div{

border-color:<?php

require_once(/*database connection script*/ );

//query the DB;

$bordercol = //db result;

echo $bordercol;

?>;

background-color:<?php....

}

 

 

 

hit me up at ([email protected])

 

THANKSSS

Link to comment
https://forums.phpfreaks.com/topic/127091-running-css-as-php-help/
Share on other sites

Yeah you want to do it the other way, run .php as .css.

 

You have a PHP file called something like 1.css

div#some_id {
background-color:{bg_color};
color:{font_color};
}

 

Then you have a PHP file called css.php:

header("Content-type: text/css");

$id = $_GET['id'];

if(file_exists("css/".$id.".css")){
$css = file_get_contents("css/".$id.".css");

/*
Replace the values that need to be replaced.
You can perform a query to get the values or whatever.
*/

echo $css; //print out the css
}

 

Then your HTML page goes like this:

 

<link rel="stylesheet" type="text/css" href="css.php?id=1" />

 

Something like that anyway. :)

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.