|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
using PHP to define variables in a CSS
Greetings all.
I am currently creating a site that allows the user to choose a "theme" with thier personal settings. I have successfully been able to load all of the inline html graphics and items with php, but what I am trying to do now is perform the same functions with a stylesheet. I have a CSS page that i renamed .php and added # styles.php header("Content-Type: text/css"); to the top so that it still sees it as a css page ... the only thing I can't figure out is how to make the page call the PHP page and use it as a CSS. i have a database set up with all the variables, etc... just need to get this past piece working. beow is the entire CSS page: __________________________________________________ <?php include("data.php"); mysql_select_db("courtad_NISP", $dbcnx2); $themes = @mysql_query(" SELECT theme FROM Affiliate_Prefs Themes WHERE affiliate_id='".$_SESSION["Affiliate_ID"]."'"); $themerow = mysql_fetch_array($themes); $styles = @mysql_query(" SELECT * FROM Themes WHERE theme_id='".$themerow[""]."' "); $stylerow = mysql_fetch_array($styles); # styles.php header("Content-Type: text/css"); ?> .menuitem { font-family: "Palatino Linotype"; line-height: 25px; font-weight: bold; background-image: url(<?PHP echo $stylerow["button"] ?>); background-repeat: no-repeat; background-position: center center; font-size: 12px; } a:link {color: #<?PHP echo $stylerow["a_link"] ?>; text-decoration: none; } a:active {color: #<?PHP echo $stylerow["a_active"] ?>; text-decoration: none; } a:visited {color: #<?PHP echo $stylerow["a_visited"] ?>; text-decoration: none; } a:hover {color: #<?PHP echo $stylerow["a_hover"] ?>; text-decoration: none; } .THL { background-image: url(<?PHP echo $stylerow["thl"] ?>); background-repeat: no-repeat; background-position: left top; } .THC { background-color: #<?PHP echo $stylerow["thc"] ?>; } .THR { background-image: url(<?PHP echo $stylerow["thr"] ?>); background-repeat: no-repeat; background-position: right top; } .TFL { background-image: url(<?PHP echo $stylerow["tfl"] ?>); background-repeat: no-repeat; background-position: left top; } .TFC { background-color: #<?PHP echo $stylerow["tfc"] ?>; } .TFR { background-image: url(<?PHP echo $stylerow["tfr"] ?>); background-repeat: no-repeat; background-position: right top; } .TCL { background-image: url(<?PHP echo $stylerow["tcl"] ?>); background-repeat: repeat-y; } .TCR { background-image: url(<?PHP echo $stylerow["tcr"] ?>); background-repeat: repeat-y; }
__________________
Thanks, Silver Tiger |
|
#2
|
|||
|
|||
|
maybe u should separate the php that processes css stuff from the css and use the php script to write to the css file.
|
![]() |
| Viewing: Dev Shed Forums > Web Design > CSS Help > using PHP to define variables in a CSS |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|